Identifier Style

ID

go.naming_identifier_style

Severity

info

Remediation Complexity

trivial

Remediation Risk

medium

Remediation Effort

low

Resource

Naming Convention

Language

Go

Tags

naming

Description

Reports poorly styled identifiers on function, type and variable declarations: an underscore inside a name where Go expects MixedCaps, and a broken initialism where a common acronym is title-cased instead of fully capitalised (IdID, UrlURL, HttpHTTP).

Rationale

Go uses MixedCaps (or mixedCaps) for compound names, not underscores, and keeps well-known initialisms fully capitalised so they read as a single unit (userID, parseURL, HTTPHandler). Consistent casing matches the standard library and avoids jarring word breaks.

// Bad
func get_user() {}        // FLAW — underscore
func fetchUrl() {}        // FLAW — Url should be URL
type HttpHandler struct{} // FLAW — Http should be HTTP

// Good
func fetchURL() {}        // OK
type HTTPHandler struct{} // OK
var httpClient int        // OK — leading lowercase word

Parameters

initialisms

Acronyms that must be fully capitalised. Defaults to a list including ID, URL, HTTP, API, JSON, SQL and others.

Remediation

Remove underscores in favour of MixedCaps, and fully capitalise the listed initialisms.