[MacPorts] #24661: go-devel: fatal error: can't find import: fmt on MacPorts
#24661: go-devel: fatal error: can't find import: fmt on MacPorts ---------------------------------+------------------------------------------ Reporter: tsumekiri@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 1.8.2 Keywords: golang go | Port: lang go-devel ---------------------------------+------------------------------------------ Hi. I installed Go on MacPorts. But helloworld program can not be comiled. I installed and compiled as follows: $ uname -a Darwin Kernel Version 10.3.0: Fri Feb 26 11:58:09 PST 2010; root:xnu- 1504.3.12~1/RELEASE_I386 i386 $ sudo port install go-devel $ cat > hello.go package main import "fmt" func main() { fmt.Printf("Hello, 世界\n") } $ 6g hello.go hello.go:3: fatal error: can't find import: fmt I tried to set GOROOT, didn't know where should I set. I'm sorry if I misunderstood something. Thank you. -- Ticket URL: <http://trac.macports.org/ticket/24661> MacPorts <http://www.macports.org/> Ports system for Mac OS
#24661: go-devel: fatal error: can't find import: fmt on MacPorts ---------------------------------+------------------------------------------ Reporter: tsumekiri@… | Owner: singingwolfboy@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 1.8.2 Keywords: | Port: go-devel ---------------------------------+------------------------------------------ Changes (by jmr@…): * keywords: golang go => * owner: macports-tickets@… => singingwolfboy@… * port: lang go-devel => go-devel Old description:
Hi.
I installed Go on MacPorts. But helloworld program can not be comiled.
I installed and compiled as follows:
$ uname -a Darwin Kernel Version 10.3.0: Fri Feb 26 11:58:09 PST 2010; root:xnu- 1504.3.12~1/RELEASE_I386 i386
$ sudo port install go-devel
$ cat > hello.go
package main
import "fmt"
func main() { fmt.Printf("Hello, 世界\n") }
$ 6g hello.go hello.go:3: fatal error: can't find import: fmt
I tried to set GOROOT, didn't know where should I set. I'm sorry if I misunderstood something.
Thank you.
New description: Hi. I installed Go on MacPorts. But helloworld program can not be comiled. I installed and compiled as follows: {{{ $ uname -a Darwin Kernel Version 10.3.0: Fri Feb 26 11:58:09 PST 2010; root:xnu- 1504.3.12~1/RELEASE_I386 i386 $ sudo port install go-devel $ cat > hello.go package main import "fmt" func main() { fmt.Printf("Hello, 世界\n") } $ 6g hello.go hello.go:3: fatal error: can't find import: fmt }}} I tried to set GOROOT, didn't know where should I set. I'm sorry if I misunderstood something. Thank you. -- Comment: Please remember to preview and use WikiFormatting, and cc the maintainer. -- Ticket URL: <http://trac.macports.org/ticket/24661#comment:1> MacPorts <http://www.macports.org/> Ports system for Mac OS
#24661: go-devel: fatal error: can't find import: fmt on MacPorts ---------------------------------+------------------------------------------ Reporter: tsumekiri@… | Owner: singingwolfboy@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 1.8.2 Keywords: | Port: go-devel ---------------------------------+------------------------------------------ Comment(by paul.richards@…): I also get this error. -- Ticket URL: <http://trac.macports.org/ticket/24661#comment:3> MacPorts <http://www.macports.org/> Ports system for Mac OS
#24661: go-devel: fatal error: can't find import: fmt on MacPorts ---------------------------------+------------------------------------------ Reporter: tsumekiri@… | Owner: singingwolfboy@… Type: defect | Status: assigned Priority: Normal | Milestone: Component: ports | Version: 1.8.2 Keywords: | Port: go-devel ---------------------------------+------------------------------------------ Changes (by singingwolfboy@…): * status: new => assigned Comment: It looks like Go compiles its packages and sticks the compiled files in `${worksrcpath}/pkg`. I didn't realize this, and I forgot to include that directory in the destroot. Oops. `man porthier` doesn't say anything about where to put `pkg` directories, so I'm not quite sure where it should go. It looks like it belongs in `lib`, but Go already creates a `lib` dir separate from `pkg`, so maybe not. Perhaps `include` -- but these are compiled files, not C sources. `share` is out because they're platform-specific. I'm going to try installing to `${prefix}/pkg` on my machine just to see if I can compile Go programs like that. Meanwhile, I'm open to other peoples' suggestions of where to store these files. -- Ticket URL: <http://trac.macports.org/ticket/24661#comment:4> MacPorts <http://www.macports.org/> Ports system for Mac OS
#24661: go-devel: fatal error: can't find import: fmt on MacPorts ---------------------------------+------------------------------------------ Reporter: tsumekiri@… | Owner: singingwolfboy@… Type: defect | Status: assigned Priority: Normal | Milestone: Component: ports | Version: 1.8.2 Keywords: | Port: go-devel ---------------------------------+------------------------------------------ Comment(by singingwolfboy@…): It looks like the deeper problem here is that Go does not allow you to change the GOBIN location once Go has been compiled (as far as I'm aware). As a result, since we compile in `${worksrcpath}/src`, Go's tools are going to look for their packages in `${worksrcpath}/pkg` rather than looking in `${prefix}`. I figured that the best place to keep Go's packages was `lib/gopkg`, since Go already has a `lib/godoc` directory. I implemented this in r67125. So the workaround to compile Go files is to specify the path to these package files with every compilation. For example, with `${prefix}` as `/opt/local`: {{{ 6g -I /opt/local/lib/gopkg/ hello.go 6l -L /opt/local/lib/gopkg/ hello.6 ./6.out Hello, 世界 }}} If anyone finds a way to change Go's GOBIN directory after it's been built, let me know! -- Ticket URL: <http://trac.macports.org/ticket/24661#comment:5> MacPorts <http://www.macports.org/> Ports system for Mac OS
#24661: go-devel: fatal error: can't find import: fmt on MacPorts ---------------------------------+------------------------------------------ Reporter: tsumekiri@… | Owner: singingwolfboy@… Type: defect | Status: assigned Priority: Normal | Milestone: Component: ports | Version: 1.8.2 Keywords: | Port: go-devel ---------------------------------+------------------------------------------ Comment(by frank.maker@…): You can add this workaround to your ~/.bash_profile file as an alias and pretend it isn't even there! {{{ alias 6g='6g -I /opt/local/lib/gopkg/' alias 6l='6l -L /opt/local/lib/gopkg/' }}} -- Ticket URL: <http://trac.macports.org/ticket/24661#comment:7> MacPorts <http://www.macports.org/> Ports system for Mac OS
#24661: go-devel: fatal error: can't find import: fmt on MacPorts ---------------------------------+------------------------------------------ Reporter: tsumekiri@… | Owner: singingwolfboy@… Type: defect | Status: assigned Priority: Normal | Milestone: Component: ports | Version: 1.8.2 Keywords: | Port: go-devel ---------------------------------+------------------------------------------ Comment(by tsumekiri@…): Thank you for your support. I can now execute "Hello, 世界" by specifying the following way. {{{ 6g -I /opt/local/lib/gopkg/ hello.go 6l -L /opt/local/lib/gopkg/ hello.6 ./6.out Hello, 世界 }}} -- Ticket URL: <http://trac.macports.org/ticket/24661#comment:8> MacPorts <http://www.macports.org/> Ports system for Mac OS
#24661: go-devel: fatal error: can't find import: fmt on MacPorts ----------------------------------+----------------------------------------- Reporter: tsumekiri@… | Owner: singingwolfboy@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 1.8.2 Resolution: fixed | Keywords: Port: go-devel | ----------------------------------+----------------------------------------- Changes (by singingwolfboy@…): * status: assigned => closed * resolution: => fixed Comment: Go now allows you to set the GOROOT differently for packaging purposes, so this bug should now be resolved. -- Ticket URL: <https://trac.macports.org/ticket/24661#comment:9> MacPorts <http://www.macports.org/> Ports system for Mac OS
participants (1)
-
MacPorts