Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the 5 secret keywords in Go?

Tags:

go

In this talk, Francesc Campoy has a slide with Go's 25 keywords, and apparently 5 'secret' keywords.

What are the 5 secret keywords in Go?

like image 841
Randomblue Avatar asked Aug 21 '16 22:08

Randomblue


People also ask

What are the keywords in go?

break , case , continue , default , else , fallthrough , for , goto , if , range , return , select and switch are used to control flow of code. defer and go are also control flow keywords, but in other specific manners.

How many keywords are in GoLang?

Keywords in GoLang: Keywords are reserved words in every language. There are 25 keywords available in the go language.

Is type a reserved word in go?

Keywords or reserved words are: break , default , func , interface , select , case , defer , go , map , struct , chan , else , goto , package , switch , const , fallthrough , if , range , type , continue , for , import , return , var .


2 Answers

The following 5 keywords are ignored:

notwithstanding
thetruthofthematter
despiteallobjections
whereas
insofaras

Yes, really.


Update: As Deleplace notes in the comments, the easter egg keywords have been removed. It looks like this commit took them out during a major parser update. If you try to run a program containing one of these tokens, you'll find they're treated as ordinary identifiers now.

like image 119
user2357112 supports Monica Avatar answered Oct 11 '22 01:10

user2357112 supports Monica


There are some easter egg keywords in the lexer (lex.go) that are not in the official documentation, and hence are ignored by the compiler.

Here they are:

notwithstanding
thetruthofthematter
despiteallobjections
whereas
insofaras

You can report to this conversation for more details.

like image 20
Ryan B. Avatar answered Oct 11 '22 01:10

Ryan B.