I’m really struggling to understand the import paths etc.
cannot find package "github.com/tcratius/hello" in any of:
cheers tc
I’m really struggling to understand the import paths etc.
cannot find package "github.com/tcratius/hello" in any of:
cheers tc
The package “github.com/tcratius/hello” has to exist in the GOPATH, in your case “/root/go”, or in your GitHub profile, installing:
go get github.com/tcratius/hello
github.com/tcratius/hello is just a directory on my computer, not linked to github.
go get github.com/tcratius/hello
# cd .; git clone https://github.com/tcratius/hello /root/go/src/github.com/tcratius/hello
Cloning into '/root/go/src/github.com/tcratius/hello'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
package github.com/tcratius/hello: exit status 128
mkdir -p $( echo $GOPATH)/src/github.com/tcratius/hello
vim $( echo $GOPATH)/src/github.com/tcratius/hello/main.go
Put in your main.go
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello")
}
Install again
go install github.com/tcratius/hello
And execute
hello
Cheers, I am not very good with vim so used nano. If I created a main.go then I have to point $GOPATH to it?
No, if you created main.go inside the “github.com/tcratius/hello”, only execute:
go install github.com/tcratius/hello
Remember that “github.com/tcratius/hello” should be within “$GOPATH/src/”
I think I’m getting the hang of it now. Thanks for your help
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.