Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

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

66%
+2 −0
Q&A 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 say that By convention, packages are given lower case, single-word names; there should be no need for underscores or...

1 answer  ·  posted 4y ago by qohelet‭  ·  last activity 4y ago by Moshi‭

#5: Post edited by user avatar qohelet‭ · 2020-10-26T02:32:46Z (about 4 years ago)
  • 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 by user avatar qohelet‭ · 2020-10-26T02:30:26Z (about 4 years ago)
  • 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 by user avatar qohelet‭ · 2020-10-26T02:30:11Z (about 4 years ago)
  • 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 by user avatar qohelet‭ · 2020-10-26T02:28:39Z (about 4 years ago)
  • 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 by user avatar qohelet‭ · 2020-10-26T02:28:02Z (about 4 years ago)
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.