The Dev Project

The Dev Project is a journey that will never stop, it’s fun and with a lot of challenges, in this publication space you will find many pieces of information about the Development World.

Member-only story

Effective Go Summary

--

Photo by Austin Distel on Unsplash

I have read Effective Go and distilled the key points into a summary. This will allow everyone to quickly grasp the essential effectiveness tips and practices. Here we go:

Package Names

When importing a package in Go, the package name becomes the access point for its contents. It’s recommended to use short, concise, and descriptive names to facilitate ease of use. Package names are typically lowercase and single-word to minimize typing. If there’s a naming collision, you can locally rename imported packages to avoid conflicts. Package names derive from the base name of their source directory, like “encoding/base64” imported as “base64.”

Example:

import (
"fmt"
b64 "encoding/base64" // Renaming for clarity
)

func main() {
encoded := b64.StdEncoding.EncodeToString([]byte("hello, world!"))
fmt.Println(encoded)
}

MixedCaps

Go conventionally uses MixedCaps (also known as camelCase) for multi-word names, rather than underscores. This style ensures consistency and readability across the language.

Example:

var myVariable int
var anotherLongVariableName string
func myFunctionName() {
// Function body
}

Getters and Setters

  • If you have a field named `owner`…

--

--

The Dev Project
The Dev Project

Published in The Dev Project

The Dev Project is a journey that will never stop, it’s fun and with a lot of challenges, in this publication space you will find many pieces of information about the Development World.

Martin Sidorov
Martin Sidorov

Written by Martin Sidorov

A passionate Software Engineer from Estonia

No responses yet