Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Can a Go package name validly contain a hyphen and/or an underscore? The godocs say that By convention, packages are given lower case, single-word names; there should be no need for underscores or...
#5: Post edited
- Can a Go package name _validly_ contain a hyphen and/or an underscore?
- [The godocs](https://golang.org/doc/effective_go.html#package-names) say that
- >By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps.
- However, this does not indicate if underscores are invalid/illegal vs. simply not following the convention, and it says nothing about hyphens.
Similarly, I searched for "hypen" and "underscore" in [a blog post on Go package names](https://blog.golang.org/package-names) and found nothing about hyphens. There was an example with an underscore in a package name with an introductory comment that it does "not fit well in Go."
- Can a Go package name _validly_ contain a hyphen and/or an underscore?
- [The godocs](https://golang.org/doc/effective_go.html#package-names) say that
- >By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps.
- However, this does not indicate if underscores are invalid/illegal vs. simply not following the convention, and it says nothing about hyphens.
- Similarly, I searched for "hypen" and "underscore" in [a blog post on Go package names](https://blog.golang.org/package-names) and found nothing about hyphens. There was an example with an underscore in a package name with an introductory comment indicating that it does "not fit well in Go," but again does not indicate whether or not it is invalid.
#4: Post edited
Can a Go package name validly contain a hyphen and/or an underscore?- [The godocs](https://golang.org/doc/effective_go.html#package-names) say that
- >By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps.
- However, this does not indicate if underscores are invalid/illegal vs. simply not following the convention, and it says nothing about hyphens.
- Similarly, I searched for "hypen" and "underscore" in [a blog post on Go package names](https://blog.golang.org/package-names) and found nothing about hyphens. There was an example with an underscore in a package name with an introductory comment that it does "not fit well in Go."
- Can a Go package name _validly_ contain a hyphen and/or an underscore?
- [The godocs](https://golang.org/doc/effective_go.html#package-names) say that
- >By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps.
- However, this does not indicate if underscores are invalid/illegal vs. simply not following the convention, and it says nothing about hyphens.
- Similarly, I searched for "hypen" and "underscore" in [a blog post on Go package names](https://blog.golang.org/package-names) and found nothing about hyphens. There was an example with an underscore in a package name with an introductory comment that it does "not fit well in Go."
#3: Post edited
- Can a Go package name validly contain a hyphen and/or an underscore?
- [The godocs](https://golang.org/doc/effective_go.html#package-names) say that
- >By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps.
- However, this does not indicate if underscores are invalid/illegal vs. simply not following the convention, and it says nothing about hyphens.
Similarly, I searched for "hypen" and "underscore" in [a blog post on Go package names](https://blog.golang.org/package-names) and found nothing.
- Can a Go package name validly contain a hyphen and/or an underscore?
- [The godocs](https://golang.org/doc/effective_go.html#package-names) say that
- >By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps.
- However, this does not indicate if underscores are invalid/illegal vs. simply not following the convention, and it says nothing about hyphens.
- Similarly, I searched for "hypen" and "underscore" in [a blog post on Go package names](https://blog.golang.org/package-names) and found nothing about hyphens. There was an example with an underscore in a package name with an introductory comment that it does "not fit well in Go."
#2: Post edited
- Can a Go package name validly contain a hyphen and/or an underscore?
- [The godocs](https://golang.org/doc/effective_go.html#package-names) say that
- >By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps.
However, this does not indicate if underscores are invalid/illegal vs. simply not following the convention.- Similarly, I searched for "hypen" and "underscore" in [a blog post on Go package names](https://blog.golang.org/package-names) and found nothing.
- Can a Go package name validly contain a hyphen and/or an underscore?
- [The godocs](https://golang.org/doc/effective_go.html#package-names) say that
- >By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps.
- However, this does not indicate if underscores are invalid/illegal vs. simply not following the convention, and it says nothing about hyphens.
- Similarly, I searched for "hypen" and "underscore" in [a blog post on Go package names](https://blog.golang.org/package-names) and found nothing.
#1: Initial revision
Are hyphens and/or underscores valid in golang package names?
Can a Go package name validly contain a hyphen and/or an underscore? [The godocs](https://golang.org/doc/effective_go.html#package-names) say that >By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps. However, this does not indicate if underscores are invalid/illegal vs. simply not following the convention. Similarly, I searched for "hypen" and "underscore" in [a blog post on Go package names](https://blog.golang.org/package-names) and found nothing.