https://github.com/devnyxie/go-lang-practice
My personal repository for Go language exercises, projects, and learning materials tailored to my study journey.
https://github.com/devnyxie/go-lang-practice
Last synced: about 1 year ago
JSON representation
My personal repository for Go language exercises, projects, and learning materials tailored to my study journey.
- Host: GitHub
- URL: https://github.com/devnyxie/go-lang-practice
- Owner: devnyxie
- Created: 2024-02-29T12:35:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-09T12:14:23.000Z (about 2 years ago)
- Last Synced: 2025-04-03T10:51:47.993Z (about 1 year ago)
- Language: Go
- Size: 115 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Go Lang Practice 🔧
```go
$ go mod init example.com/example -> Initializes module in current dir
$ go mod tidy -> Cleans & updates dependencies in go.mod
```
# Code Style: Camel Case or Snake Case?
In Go, there are some common naming conventions for variables, functions, and other identifiers: [1]
snake_case is commonly used for variable and function names. All lowercase letters separated by underscores. For example: function_name, variable_name.
CamelCase is used for type names (structs, interfaces, etc) and exported (public) identifiers. The first letter of each internal word is capitalized. For example: MyType, ExportedFunction.
leading underscores for private variables/functions - _privateVar. These are not exported.
Some key points:
snake_case is preferred over camelCase for non-exported identifiers by many Go programmers.
Exported identifiers use CamelCase so they are accessible from other packages.
The naming convention helps identify what kind of entity something is (variable, type, exported function) at a glance.
So in summary, snake_case is commonly used for local variables and functions, while CamelCase is used for exported/public types and identifiers that need to be accessible from other packages. Following common conventions helps make code more readable and maintainable.