debian-mirror-gitlab/workhorse/internal/utils/svg
2022-07-29 14:03:07 +02:00
..
LICENSE New upstream version 13.7.7 2021-02-22 17:27:13 +05:30
README.md New upstream version 15.1.3+ds1 2022-07-29 14:03:07 +02:00
svg.go New upstream version 13.7.7 2021-02-22 17:27:13 +05:30

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"
	"os"

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

func main() {
	buf, err := os.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