abbreviation naming convention

4,781 views
Skip to first unread message

jonathan...@gmail.com

unread,
Jul 8, 2015, 4:01:13 PM7/8/15
to golan...@googlegroups.com
I could have sworn I read that go convention is for uppercase abbreviations as found in the stdlib like ServeHTTP and not ServeHttp but I can not find a doc anywhere. Was I imagining this?

Tim K

unread,
Jul 8, 2015, 4:32:36 PM7/8/15
to golan...@googlegroups.com, jonathan...@gmail.com
You are correct, that is the recommendation:

See "Initialisms" section here:
https://code.google.com/p/go-wiki/wiki/CodeReviewComments

And slide 6 here:
http://talks.golang.org/2014/names.slide#6

jonathan...@gmail.com

unread,
Jul 9, 2015, 3:41:17 PM7/9/15
to golan...@googlegroups.com, jonathan...@gmail.com
Ah thanks!

Matt Silverlock

unread,
Jul 9, 2015, 7:23:48 PM7/9/15
to golan...@googlegroups.com, jonathan...@gmail.com
golint (https://github.com/golang/lint) also yells at you for this in common cases (Id -> ID, Http -> HTTP, etc). Note that some of the std. lib predates this (e.g. http.Cookie fields) but can't be changed without breaking the Go1 compatibility guarantee.

Jamel Toms

unread,
Aug 25, 2020, 1:07:08 PM8/25/20
to golang-nuts
Is there a rationale for this? At face-value it seems purely arbitrary and personal preference. 

It would be nice if it just stated that in the comments as opposed positioning itself as if there's something inherently better about this naming convention.

Kurtis Rader

unread,
Aug 25, 2020, 1:28:12 PM8/25/20
to Jamel Toms, golang-nuts
The rationale for uppercase abbreviations in Go symbol name derives from the english convention for writing acronyms using all uppercase letters. For example: NASA, ASCII, LOL, etc. That provides a visual clue the "word" is an acronym.

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ba980968-5445-44ef-924d-87f801e00cacn%40googlegroups.com.


--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

Jamel Toms

unread,
Aug 25, 2020, 5:07:16 PM8/25/20
to Kurtis Rader, golang-nuts
That makes sense, I never considered following that rule in code very important. I still think it's a personal preference, but at least I understand the rationale. It follows the spirit of Go lang with minimizing ambiguity.
--
Reply all
Reply to author
Forward
0 new messages