Friday, November 13, 2009

fatal error: can't find import: fmt?

If you have those problem - it means that you should define $GOROOT, $GOOS and $GOARCH variables. And if you are very lazy (as me :) ) you'l need a bash script to define vars and compile source code. So create new file, for expample "compile" and add to it


#!/bin/bash
export GOROOT=/home/your-name/hg
export GOOS=linux
export GOARCH=386
8g main.go
8l main.8
./8.out
read -p "Press [enter] to continue..."



If script doesn't work - cher path to the bash (for me it's /bin/bash), path to /hg and architecture. Also if you have 64-bit x86 system - you should write instead 8 write 6. If 32-bit x86, and more - 8.
And don't forget put execution rights ot this file.

5 comments:

  1. I have these variables:
    export GOROOT=$HOME/Go
    export GOARCH=386
    export GOOS=darwin
    export GOBIN=$HOME/Go/binz

    Even though I get this error:
    desertfather:binz Cato$ 8g main.go
    main.go:7: fatal error: can't find import: ./irc

    And an ls in the binz folder shows the IRC folder =/

    ReplyDelete
  2. did you write "irc" import?
    Because I can't see any "irc" in documentation. If yes - write right path to this.

    ReplyDelete
  3. http://github.com/jteeuwen/go-app-irc/ <= The irc import is in this package.

    desertfather:src Cato$ ls
    irc main.go text

    desertfather:src Cato$ 8g main.go
    main.go:7: fatal error: can't find import: ./irc

    ReplyDelete
  4. Nevermind! I figured it out. Noobish really :P I had to compile the libraries as well :)

    ReplyDelete
  5. I have the same issue for the oh shell. I have been trying to make a PKGBUILD for it.

    here is go-tecla:
    https://aur.archlinux.org/packages.php?ID=50005

    here is oh:
    https://aur.archlinux.org/packages.php?ID=50007

    I would be very happy if someone sees what I have been doing wrong. The official instructions only show how to do it with goinstall but that is not very packaging-friendly

    ReplyDelete