gitlab-org--gitlab-foss/workhorse/internal/utils/svg
GitLab Bot 1bdf79827c Add latest changes from gitlab-org/gitlab@master 2020-12-02 15:09:37 +00:00
..
LICENSE Add latest changes from gitlab-org/gitlab@master 2020-12-02 15:09:37 +00:00
README.md Add latest changes from gitlab-org/gitlab@master 2020-12-02 15:09:37 +00:00
svg.go Add latest changes from gitlab-org/gitlab@master 2020-12-02 15:09:37 +00:00

README.md

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