golang / freetype

The Freetype font rasterizer in the Go programming language.
Other
791 stars 183 forks source link

Should go.mod not be added to the project? #71

Open tithamane opened 5 years ago

tithamane commented 5 years ago

I'm learning how to use go modules and trying to convert my project to use them but I'm getting an error from this package when try to build it.

When I run: go get github.com/golang/freetype then I get

go: finding github.com/golang/freetype latest go: finding github.com/golang/freetype/truetype latest go build github.com/golang/freetype/truetype: no Go files in

When I try to build my code I get

go: finding github.com/golang/freetype/truetype latest go: finding github.com/golang/freetype latest ../../../go/pkg/mod/github.com/llgcode/draw2d@v0.0.0-20180825133448-f52c8a71aff0/draw2dimg/ftgc.go:16:2: unknown import path "github.com/golang/freetype/truetype": cannot find module providing packagegithub.com/golang/freetype/truetype

It could just be the fact that I'm not using these modules properly or maybe I need to restructure my code, I just though I should ask about this just in case it could help solve my problem.

If I can get it working again, I'll close this issue.

scottgreenup commented 5 years ago

I can get this working with go modules.

Log ``` $ go mod init foo go: creating new go.mod: module foo $ go get -u github.com/golang/freetype go: finding github.com/golang/freetype latest go: finding golang.org/x/image/math/fixed latest go: finding golang.org/x/image/font latest go: finding golang.org/x/image/math latest go: finding golang.org/x/image latest $ cat main.go package main import ( "fmt" "github.com/golang/freetype" ) func main() { context := freetype.NewContext() fixed := context.PointToFixed(64.0) fmt.Printf("%d\n",fixed) } $ go build . $ ./foo 4096 ```

You shouldn't need go.mod/go.sum for this to work. Can you share how you created your repo (the commands you ran), and where it is in relation to your GOPATH? I think you might have issues with it being in your GOPATH, based on the ../../../go/pkg, I'd recommend moving it out of your GOPATH or trying export GO111MODULE=on then building again.