Fork and add module

The upstream harukasan/go-libwebp hasn't been updated in almost three
years, so we're officially forking this into tidbyt/go-libwebp and
making it a Go module.
This commit is contained in:
Rohan Singh 2022-03-01 22:30:23 -05:00
parent 7718986fb5
commit dd1cead28d
12 changed files with 29 additions and 133 deletions

View file

@ -10,29 +10,24 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
)
// GetExFilePath returns the path of specified example file.
func GetExFilePath(name string) string {
for _, gopath := range strings.Split(os.Getenv("GOPATH"), ":") {
path := filepath.Join(gopath, "src/github.com/harukasan/go-libwebp/examples/images", name)
if _, err := os.Stat(path); err == nil {
return path
}
path := filepath.Join("../examples/images", name)
if _, err := os.Stat(path); err == nil {
return path
}
panic(fmt.Errorf("%v does not exist in any directory which contains in $GOPATH", name))
panic(fmt.Errorf("%v does not exist", path))
}
// GetOutFilePath returns the path of specified out file.
func GetOutFilePath(name string) string {
for _, gopath := range strings.Split(os.Getenv("GOPATH"), ":") {
path := filepath.Join(gopath, "src/github.com/harukasan/go-libwebp/examples/out")
if _, err := os.Stat(path); err == nil {
return filepath.Join(path, name)
}
path := "../examples/out"
if _, err := os.Stat(path); err == nil {
return filepath.Join(path, name)
}
panic(fmt.Errorf("out directory does not exist in any directory which contains in $GOPATH"))
panic(fmt.Errorf("out directory does not exist"))
}
// OpenFile opens specified example file

View file

@ -1,54 +0,0 @@
package util_test
import (
"testing"
"github.com/harukasan/go-libwebp/test/util"
)
var PNGFiles = []string{
"butterfly.png",
"cosmos.png",
"fizyplankton.png",
"kinkaku.png",
"yellow-rose-3.png",
}
var WebPFiles = []string{
"butterfly.webp",
"cosmos.webp",
"fizyplankton.webp",
"kinkaku.webp",
"yellow-rose-3.webp",
}
func TestOpenFile(t *testing.T) {
for _, file := range PNGFiles {
util.OpenFile(file)
}
for _, file := range WebPFiles {
util.OpenFile(file)
}
}
func TestReadFile(t *testing.T) {
for _, file := range PNGFiles {
util.ReadFile(file)
}
for _, file := range WebPFiles {
util.ReadFile(file)
}
}
func TestCreateFile(t *testing.T) {
f := util.CreateFile("util_test")
f.Write([]byte{'o', 'k'})
f.Close()
}
func TestReadWritePNG(t *testing.T) {
for _, file := range PNGFiles {
png := util.ReadPNG(file)
util.WritePNG(png, "util_test_"+file)
}
}