go build current weekly gives: runtime.main: undefined: main.init. Direct 6g/6l is fine.

1,072 views
Skip to first unread message

gmallard

unread,
Feb 10, 2012, 8:10:05 PM2/10/12
to golang-nuts
Hi. I have a very strange problem with a very simple sample program.

Running 'go build' gives me:

[gmallard@tjjackson switch_test (swwork)]$ go build
# go-samp/switch_test
runtime.main: undefined: main.init
runtime.main: undefined: main.main

Running a direct compile and link is fine:

[gmallard@tjjackson switch_test (swwork)]$ $GOROOT/bin/tool/6g
switch_test.go
[gmallard@tjjackson switch_test (swwork)]$ $GOROOT/bin/tool/6l
switch_test.6
[gmallard@tjjackson switch_test (swwork)]$ ./6.out
Start...
Dunno
End...

Here is the code:

package main

import (
"fmt" //
)
func main() {
fmt.Println("Start...")
anint := 256
switch anint {
case 1:
fmt.Println("Is 1")
case 2:
fmt.Println("Is 2")
case 3:
fmt.Println("Is 3")
default:
fmt.Println("Dunno")
}
fmt.Println("End...")
}

For reference:

[gmallard@tjjackson switch_test (swwork)]$ go version
go version weekly.2012-02-07 +52ba9506bd99

It is perplexing, because I have spent the greater part of today
converting a number of programs from 'make' to 'go' builds. All else
looks good.

Thanks, Guy




gmallard

unread,
Feb 10, 2012, 8:51:45 PM2/10/12
to golang-nuts
Solution: do not name normal files with _test at the end of the file
name.

Thanks Rémy and Dave.
Reply all
Reply to author
Forward
0 new messages