You are not logged in.
I have installed go and tried to write a simple program, hello.go.
package main
import "fmt"
func main() {
fmt.Println("Hello this is frustrating")
}
Whenever I try and compile the program with 'g6 hello.go' I get an error (I am running 64bit btw)
$ 6g hello.go
hello.go:3: can't find import: fmt
I have added the following to my .bashrc aswell and still get that error
export GOROOT=$HOME/Go/src
export GOARCH=amd64
export GOOS=linux
export GOBIN=$HOME/Go/bin
export PATH=$PATH:$GOBIN
Last edited by slughappy1 (2011-10-27 18:09:27)
Offline
My GOROOT points at the root 'go' directory, you are pointing it at Go/src (you renamed it to an uppercase 'G' I guess), so try pointing GOROOT at $HOME/Go instead.
Offline
I see that many of the replies disappeared due to the database corruption. Do you still have problems with this?
Offline
I see that many of the replies disappeared due to the database corruption. Do you still have problems with this?
As a matter of fact I am still having problems. I installed go from the repo, and I still can't get it to compile. I have a file /etc/profile.d/go.sh with the following in it.
export GOROOT=/usr/lib/go
export GOOS=linux
export GOBIN=/usr/bin
I also edited my ~/.bashrc to include
# For programming language Go
export GOROOT=$HOME/go/src
export GOARCH=amd64
export GOOS=linux
export GOBIN=$HOME/go/bin
export PATH=$PATH:$GOBIN
When I try and write a simple program hello.go it wont compile
$ 6g hello.go
hello.go:3: can't find import: fmt
The file hello.go only has the example code taken from the first page of golang.org
package main
import "fmt"
func main() {
fmt.Println("Hello")
}
Offline
I think your problem is having GOROOT redefined to your home directory. Do you really have a copy of fmt package in there? I believe you should just use what is provided with /etc/profile.d/go.sh. That's what I do and it works.
Satisfied users don't rant, so you'll never know how many of us there are.
Offline
I think your problem is having GOROOT redefined to your home directory. Do you really have a copy of fmt package in there? I believe you should just use what is provided with /etc/profile.d/go.sh. That's what I do and it works.
So do I not really need anything in my .bashrc?
Offline
Or I suppose I should ask what do I need in my .bashrc relating to Go?
Offline
So it turns out I was just mixing things up. I added to my .bashrc file
# For programming language Go
export GOROOT=/usr/lib/go
export GOARCH=amd64
export GOOS=linux
export GOBIN=/usr/bin
export PATH=$PATH:$GOBIN
And now I can compile programs. Thanks for the help.
Offline
Ok, I didn't install from Arch repo but did a hg pull from the Go weekly releases, hence I don't have a /etc/profile.d/go.sh . Also I've only added GOROOT, GOARCH and GOOS, no need to add GOBIN since the binaries are located under the GOROOT hierarchy.
Offline
So it turns out I was just mixing things up. I added to my .bashrc file
# For programming language Go
export GOROOT=/usr/lib/go
export GOARCH=amd64
export GOOS=linux
export GOBIN=/usr/bin
export PATH=$PATH:$GOBINAnd now I can compile programs. Thanks for the help.
Sorry for the late answer, but, if you have /etc/profile.d/go.sh, you wouldn't need anything added on .bashrc.
@Grynch: in your case, you will need to add those variables in .bashrc.
Satisfied users don't rant, so you'll never know how many of us there are.
Offline
@Grynch: in your case, you will need to add those variables in .bashrc.
Yes I know, I've had no problem with Go. What I wrote was in relation to this discussion as it were before the forum database had to be restored resulting in posts gone missing.
Offline