Go.Tips
12 subscribers
7 photos
15 links
Useful tips, libraries and information for Go (Golang) developers

Rust::Tips: @rust_code_tips
My GitHub: https://github.com/ankddev
Download Telegram
Cobra
Cobra is a library for creating powerful modern CLI applications.
Cobra is used in many Go projects such as KubernetesHugo, and GitHub CLI to name a few.
Features:
- Easy subcommand-based CLIs: app server, app fetch, etc.
- Fully POSIX-compliant flags (including short & long versions)
- Nested subcommands
- Global, local and cascading flags
Intelligent suggestions (app srver... did you mean app server?)
- Automatic help generation for commands and flags
- Grouping help for subcommands
Automatic help flag recognition of -h, --help, etc.
- Automatically generated shell autocomplete for your application (bash, zsh, fish, powershell)
- Automatically generated man pages for your application
- Command aliases so you can change things without breaking them
- The flexibility to define your own help, usage, etc.
- Optional seamless integration with viper for 12-factor apps
GitHub
Website
#library #project #showcase #cli
@golang_tips
TypeScript became 10x faster with native version on Go!
Microsoft announced native version of TypeScript compiler. It is written in Go.

Compilation became faster in 10x, autocompletions, refactoring, etc. became blazingly fast.

GitHub
#showcase #project #news
@golang_tips
👍1
Check that Interface value is equal to nil
If interface contains nil, it can be not equal nil, e.g.
func main() { 
var x interface{}
var y *int = nil
x = y

if x != nil {
fmt.Println("x != nil") // <-- actual
} else {
fmt.Println("x == nil")
}
fmt.Println(x) } // x != nil // <nil>

prints
x != nil
<nil>

To correctly check if interface is equal to nil, you can write function, similar to
func IsNil(x interface{}) bool {
if x == nil {
return true
}

return reflect.ValueOf(x).IsNil()
}

This function will work as expected.
#tip #example
@golang_tips
new vs make
Both make() and new() are used for memory allocation. But make() returns initialized type value, while new() returns nil-pointer to type.
a := new(chan int) // a has *chan int type
b := make(chan int) // b has chan int type

#tip #example
@golang_tips
A beginner-friendly guide to Go
It is comprehensive guide for those new to Go programming. The book takes readers from basics through more advanced concepts including:

- Core language fundamentals
- Working with interfaces
- Mastering goroutines and channels
- Writing effective tests and much more

Leanpub: https://leanpub.com/myfirstgobook
#book #learning
@golang_tips
Docker
Docker is a popular containerization software. And yes, it is written in Go! This fact allows Docker to be fast and efficient.
#showcase #fact
@golang_tips
Go's mascot
Go has it's official mascot - Gopher. It has long history and very cute.
#fact
@golang_tips
Glance
A self-hosted dashboard that puts all your feeds in one place.

GitHub
#showcase #project
@golang_tips
👍1
Go 1.24.2 and 1.23.8 were released!
These updates are minor and focusing on security updates.

Announce: https://groups.google.com/g/golang-announce/c/Y2uBTVKjBQk/m/cs_6qIK5BAAJ
Download: https://go.dev/dl/#go1.24.2
#update
@golang_tips
Chezmoi
Manage your dotfiles across multiple diverse machines, securely.
Website
GitHub

Also you can find my dotfiles, managed by Chezmoi here.
#showcase #project