svg

package
v8.8.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2019 License: MIT, MIT Imports: 2 Imported by: 0

README

go-is-svg

Tiny package to verify if a given file buffer is an SVG image in Go (golang).

Installation

go get -u github.com/h2non/go-is-svg

Example

package main

import (
	"fmt"
	"io/ioutil"

	svg "github.com/h2non/go-is-svg"
)

func main() {
	buf, err := ioutil.ReadFile("_example/example.svg")
	if err != nil {
		fmt.Printf("Error: %s\n", err)
		return
	}

	if svg.Is(buf) {
		fmt.Println("File is an SVG")
	} else {
		fmt.Println("File is NOT an SVG")
	}
}

Run example:

go run _example/example.go

License

MIT - Tomas Aparicio

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Is

func Is(buf []byte) bool

Is returns true if the given buffer is a valid SVG image.

func IsSVG

func IsSVG(buf []byte) bool

IsSVG returns true if the given buffer is a valid SVG image. Alias to: Is()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL