chai2010 / webp

WebP decoder and encoder for Go (Zero Dependencies).
http://godoc.org/github.com/chai2010/webp
BSD 3-Clause "New" or "Revised" License
512 stars 89 forks source link

undefined问题 #71

Open homeeecode3 opened 3 weeks ago

homeeecode3 commented 3 weeks ago

按照文档的方式写了示例代码: package main

import ( "bytes" "fmt" "io/ioutil" "log"

"github.com/chai2010/webp"

)

func main() { var buf bytes.Buffer var width, height int var data []byte var err error

// Load file data
if data, err = ioutil.ReadFile("./testdata/1_webp_ll.webp"); err != nil {
    log.Println(err)
}

// GetInfo
if width, height, _, err = webp.GetInfo(data); err != nil {
    log.Println(err)
}
fmt.Printf("width = %d, height = %d\n", width, height)

// GetMetadata
if metadata, err := webp.GetMetadata(data, "ICCP"); err != nil {
    fmt.Printf("Metadata: err = %v\n", err)
} else {
    fmt.Printf("Metadata: %s\n", string(metadata))
}

// Decode webp
m, err := webp.Decode(bytes.NewReader(data))
if err != nil {
    log.Println(err)
}

// Encode lossless webp
if err = webp.Encode(&buf, m, &webp.Options{Lossless: true}); err != nil {
    log.Println(err)
}
if err = ioutil.WriteFile("output.webp", buf.Bytes(), 0666); err != nil {
    log.Println(err)
}

fmt.Println("Save output.webp ok")

}

go.mod中: module test_prj

go 1.20

require ( github.com/chai2010/webp v1.1.1 )

go run 的时候报错:

github.com/chai2010/webp

/root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:22:9: undefined: webpGetInfo /root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:26:20: undefined: webpDecodeGray /root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:39:20: undefined: webpDecodeRGB /root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:52:20: undefined: webpDecodeRGBA /root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:68:14: undefined: webpDecodeGrayToSize /root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:82:14: undefined: webpDecodeRGBToSize /root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:96:14: undefined: webpDecodeRGBAToSize /root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:109:7: undefined: toGrayImage /root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:110:14: undefined: webpEncodeGray /root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:119:14: undefined: webpEncodeRGB /root/go/pkg/mod/github.com/chai2010/webp@v1.1.1/webp.go:119:14: too many errors

golang版本: go version go1.20.14 linux/amd64

peach-zhang commented 1 week ago

我也出现了