Naming conventions for constants in Go: CamelCase, ALL_CAPS, or something else?
Hi everyone! I've just started learning Go after Python and C#, and I'm a bit confused about the naming conventions for constants.
In Python we usually use `ALL_CAPS` for constants: `MAX_CONNECTIONS = 100`. In C# it's common to use `PascalCase`. But in Go, I see different code in different projects.
For example, in the Go standard library I came across these examples:
```go
// In the http package
const (
MethodGet = "GET"
MethodPost = "POST"
)
// In the os package
const (
O_RDONLY = 0x0
O_WRONLY = 0x1
)
```
The first example uses CamelCase (`MethodGet`), and the second uses snake_case with uppercase letters (`O_RDONLY`). When I asked a colleague, he said that in Go you should use `CamelCase` for exported constants and `lowerCamelCase` for unexported ones. But then why does `os`
No answers yet.
Log in to leave an answer
Blogs