Skip to content

Check if a given buffer is a valid SVG image in Go (golang)

License

Notifications You must be signed in to change notification settings

h2non/go-is-svg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-is-svg Build Status GoDoc Coverage Status Go Report Card

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

See also filetype package for binary files type inference.

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

About

Check if a given buffer is a valid SVG image in Go (golang)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages