Skip to content

doc: document that "main" is a reserved import path #6312

@gopherbot

Description

@gopherbot

by Kevapo:

What steps will reproduce the problem?
1. create a package main, with a few file, and a Main.go file (with main method)
2. create a main_test.go inside this package (with a simple test that use the data or
methods inside the package main)
3. go test main

What is the expected output? ==> that it will launch the tests inside main_test.go

What do you see instead?
kevapo@ubuntu:~/workspace/dtstrike/starters/Go/src/main$ go test -x -v
WORK=/tmp/go-build574310510
mkdir -p $WORK/main/_test/
cd /home/kevapo/workspace/dtstrike/starters/Go/src/main
/usr/local/go/pkg/tool/linux_amd64/6g -o $WORK/main/_test/_go_.6 -p main -complete -D
_/home/kevapo/workspace/dtstrike/starters/Go/src/main -I $WORK ./GameState.go ./Main.go
./MyBot.go ./PlanetSystem.go ./main_test.go
/usr/local/go/pkg/tool/linux_amd64/pack grcP $WORK $WORK/main/_test/main.a
$WORK/main/_test/_go_.6
cd $WORK/main/_test
/usr/local/go/pkg/tool/linux_amd64/6g -o ./_go_.6 -p testmain -complete -D ""
-I . -I $WORK ./_testmain.go
# testmain
/tmp/go-build574310510/main/_test/_testmain.go:9: cannot import "main"
$WORK/main/_test/main.test -test.v=true
FAIL    main [build failed]

Version : 
go version go1.1.1 linux/amd64 on ubuntu

Attachments:

  1. main.zip (8312 bytes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions