Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tithamane opened this issue Jan 31, 2019 · 1 comment
Open

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

tithamane opened this issue Jan 31, 2019 · 1 comment

Comments

@tithamane
Copy link

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/[email protected]/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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants