Take the 2-minute tour ×

There is a file pig.go on the golang.org website:

    in a box labeled doc/codewalk/pig.go

Compiling it with gccgo version (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1

    gccgo pig.go 

gives an error message about not finding math/rand

    pig.go:9:11: error: import file ‘math/rand’ not found
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Your version of gccgo implements an old version of the language. To compile Go 1 code, you need gccgo 4.7.1 or later.

If you can't or don't want to upgrade, you could probably just change the import from math/rand to rand and it will compile with gccgo 4.6.1. Not all programs will be so easy to backport, but this one happens to be.

share|improve this answer
Thanks Evan! With just "rand" and not "math/rand" it compiles and runs fine. –  Scooter Jul 22 '12 at 0:29
add comment

Your Answer


