The key here is to understand that the go tool works with import paths, not 
files or directories. This statement isn't absolutely true as there are 
many inconsistencies that water down this statement, but if you're ever 
stuck about how to do something with the Go tool, think about "how do I 
import this code into my package". For example, you want to access the 
symbols in the crypto/tls package, you write

   import "crypto/tls"

If you want to test the code in the crypto/tls package, you run

   go test crypto/tls

Obviously the go tool can work with directories; for example

  go test ./internal/foo

Which says "assuming that the current directory is imported as x/y/x, run 
the tests of package x/y/x/internal/foo", but that introduces confusing 
ideas like relative import paths, a wish that symlinks worked (they don't), 
and so on. So if you're stuck, try to think about using the go tool in the 
same way you import a piece of code into your package.

Hope that helps

Dave

On Sunday, 22 October 2017 10:24:03 UTC+11, Dave Cheney wrote:
>
> Hi,
>
> I think you've got a bit confused here. If you want to run the tests of a 
> package in the standard library; you must use the source that matches the 
> version of Go you have installed; that is the version in $(go env GOROOT). 
>
> Try this command
>
> go test -bench=. crypto/tls
>
> On Sunday, 22 October 2017 10:05:49 UTC+11, Leon Klingele wrote:
>>
>> So how _do_ I run the crypto/tls benchmarks of github.com/golang/go?
>>
>> $ cd $GOPATH/src/github.com/golang/go/src/crypto/tls
>> $ git rev-parse HEAD
>> 5f740d6875ab6961381f2f4614b21ff6ddf448a4
>> $ go test -bench=.
>> common.go:10:2: use of internal package not allowed
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to