Use inclusive language in type declarations

Metadata

ID: go-inclusive/types

Language: Go

Severity: Notice

Category: Best Practices

Description

Use inclusive language in types definitions.

Non-Compliant Code Examples

import "fmt"

type Master struct {
	ipAddress string
}

type MasterType Master

type (
	Slave        int
	BlaCKlist    []Master
	myWhiteLists [][]string
)

func main() {
	// Variable names caught in variables rule
	master := Master{ipAddress: "127.0.0.1"}
	master2 := new(Master)
	master3 := make(Blacklist, 0, 0)

	fmt.Println(master)
	fmt.Println(master2)
	fmt.Println(master3)
}

Compliant Code Examples

type dog struct {
	name string
	age  int
}

func main() {
	cat := struct {
		name string
		age  int
	}{
		"Ginger",
		11,
	}
	fmt.Println(cat)

	dog := dog{name: "Oreo", age: 12}

	fmt.Println(dog)

}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis