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

60%
+1 −0
Q&A Are hyphens and/or underscores valid in golang package names?

Disclaimer: I don't know Go. This is all just me reading the specification. In the Go specification under Packages, it defines PackageName. PackageName = identifier Under Identifiers identi...

posted 3y ago by Moshi‭  ·  edited 3y ago by Moshi‭

Answer
#2: Post edited by user avatar Moshi‭ · 2020-10-26T04:09:39Z (over 3 years ago)
  • Disclaimer, I don't know Go.
  • -----
  • In the Go specification, [Packages](https://golang.org/ref/spec#Packages)
  • > ```
  • > PackageName = identifier
  • > ```
  • Under [Identifiers](https://golang.org/ref/spec#Identifiers)
  • > ```
  • > identifier = letter { letter | unicode_digit } .
  • > ```
  • Under [Letters and digits](https://golang.org/ref/spec#Letters_and_digits)
  • > ```
  • > letter = unicode_letter | "_" .
  • > ```
  • Finally, under [Characters](https://golang.org/ref/spec#Characters)
  • > ```
  • > unicode_letter = /* a Unicode code point classified as "Letter" */ .
  • > unicode_digit = /* a Unicode code point classified as "Number, decimal digit" */ .
  • > ```
  • So it seems according to the specification, any Unicode letter or number, as well as underscores are technically legal.
  • Disclaimer: I don't know Go. This is all just me reading the specification.
  • -----
  • In the Go specification under [Packages](https://golang.org/ref/spec#Packages), it defines `PackageName`.
  • > ```
  • > PackageName = identifier
  • > ```
  • Under [Identifiers](https://golang.org/ref/spec#Identifiers)
  • > ```
  • > identifier = letter { letter | unicode_digit } .
  • > ```
  • Under [Letters and digits](https://golang.org/ref/spec#Letters_and_digits)
  • > ```
  • > letter = unicode_letter | "_" .
  • > ```
  • **Underscores are therefore legal, according to the spec.**
  • Under [Characters](https://golang.org/ref/spec#Characters), it says what constitutes a `unicode_letter` and `unicode_digit`.
  • > ```
  • > unicode_letter = /* a Unicode code point classified as "Letter" */ .
  • > unicode_digit = /* a Unicode code point classified as "Number, decimal digit" */ .
  • > ```
  • > In [The Unicode Standard 8.0](https://www.unicode.org/versions/Unicode8.0.0/), Section 4.5 "General Category" defines a set of character categories. Go treats all characters in any of the Letter categories Lu, Ll, Lt, Lm, or Lo as Unicode letters, and those in the Number category Nd as Unicode digits.
#1: Initial revision by user avatar Moshi‭ · 2020-10-26T03:34:43Z (over 3 years ago)
Disclaimer, I don't know Go.

-----

In the Go specification, [Packages](https://golang.org/ref/spec#Packages)

> ```
> PackageName    = identifier
> ```

Under [Identifiers](https://golang.org/ref/spec#Identifiers)

> ```
> identifier = letter { letter | unicode_digit } .
> ```

Under [Letters and digits](https://golang.org/ref/spec#Letters_and_digits)

> ```
> letter        = unicode_letter | "_" .
> ```

Finally, under [Characters](https://golang.org/ref/spec#Characters)

> ```
> unicode_letter = /* a Unicode code point classified as "Letter" */ .
> unicode_digit  = /* a Unicode code point classified as "Number, decimal digit" */ .
> ```

So it seems according to the specification, any Unicode letter or number, as well as underscores are technically legal.