FAQ
I've seen that the example code files in Go repository use a package name
adding the suffix "_test"; i.e. for "package strings", would be "package
strings_test"

http://golang.org/src/pkg/strings/example_test.go

I've checked that "go test" work using directly "package strings". Any
reason to add the suffix?

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Dan Kortschak at Aug 23, 2014 at 8:55 pm
    Since they are examples, it's nice to have the code look exactly as it would in a client's package with a "strings" import.

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Patrick Juchli at Aug 23, 2014 at 9:57 pm
    As soon as your tests are not using the same package name you loose access
    to internal methods, variables, etc.

    It forces you to test against the public API of your package to make your
    tests less brittle. I find it also helps me determine if my public API is
    usable or not.

    On Saturday, August 23, 2014 10:16:17 PM UTC+2, Archos wrote:

    I've seen that the example code files in Go repository use a package name
    adding the suffix "_test"; i.e. for "package strings", would be "package
    strings_test"

    http://golang.org/src/pkg/strings/example_test.go

    I've checked that "go test" work using directly "package strings". Any
    reason to add the suffix?
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Patrick Juchli at Aug 23, 2014 at 10:02 pm
    And because you can only have one package in a folder, you have to follow
    the [package name]_test convention as it is the exception to this rule.
    On Saturday, August 23, 2014 11:57:28 PM UTC+2, Patrick Juchli wrote:

    As soon as your tests are not using the same package name you loose access
    to internal methods, variables, etc.

    It forces you to test against the public API of your package to make your
    tests less brittle. I find it also helps me determine if my public API is
    usable or not.

    On Saturday, August 23, 2014 10:16:17 PM UTC+2, Archos wrote:

    I've seen that the example code files in Go repository use a package name
    adding the suffix "_test"; i.e. for "package strings", would be "package
    strings_test"

    http://golang.org/src/pkg/strings/example_test.go

    I've checked that "go test" work using directly "package strings". Any
    reason to add the suffix?
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 23, '14 at 8:16p
activeAug 23, '14 at 10:02p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase