Go

Go

Made by DeepSource
Use (*mail.Address).String() instead of fmt.Sprintf for mail address GO-W1031
Bug risk
Major
Autofix

For a name and address that is supposed to formatted to a single mail address, it is recommended to use net/mail's (*Address).String instead of manually formatting using fmt.Sprintf which makes the code much more reliable.

Printf-like function without f suffix GO-W6006
Bug risk
Major

For Printf-like functions they should be named correctly so that consumers of the function use it correctly. It is recommended to use f as suffix for such functions to make it clear that arguments are preceded with format specifier.

Defers in infinite loops will never execute SCC-SA5003
Bug risk
Major

Defers are scoped to the surrounding function, not the surrounding block. In a function that never returns, i.e. one containing an infinite loop, defers will never execute.

The empty for loop (for {}) spins and can block the scheduler SCC-SA5002
Bug risk
Major

An empty loop is bad news in two cases: 1) The loop has no condition. In that case, it's just a loop that spins forever and as fast as it can, keeping a core busy.

Useless assignment VET-V0002
Bug risk
Major
Autofix

Useless assignments are usually a result of error. For example:

Using bytes.Equal to compare two net.IP SCC-SA1021
Bug risk
Major
Autofix

A net.IP stores an IPv4 or IPv6 address as a slice of bytes. The length of the slice for an IPv4 address, however, can be either 4 or 16 bytes long, using different ways of representing IPv4 addresses.

Invalid template SCC-SA1001
Bug risk
Critical

Issue is raised when templates cannot be parsed by the Parse function of html/template or text/template. For example, {{.Name}} {{.LastName} can not be parsed and causes runtime errors.

Using an invalid host:port pair with net.Listen SCC-SA1020
Bug risk
Major

Valid host:port pair should be of format hostname:n where n >= 0 && n <= 65535. Passing invalid host:port pair causes bug risk and potential security exposure.

Comparing a value against NaN even though no value is equal to NaN SCC-SA4012
Bug risk
Major

Generally, NaN is not considered equal to any number, including itself. That's because it represnts a number outside the range of representation.

Slice index out of bounds SCC-SA5006
Bug risk
Critical

A function that calls itself recursively needs to have an exit condition. Otherwise it will recurse forever, until the system runs out of memory.

Infinite recursive call SCC-SA5007
Bug risk
Major

A function that calls itself recursively needs to have an exit condition. Otherwise it will recurse forever, until the system runs out of memory.

Some violation of cgo pointer passing rules VET-V0006
Bug risk
Critical

Attempts to pass a Go chan, map, func, or slice to C, either directly, or via a pointer, array, or struct is not recommended. This is because the values of these types (apart from zero-value) always contain Go pointers, which is not

strings.Replace/ bytes.Replace called with n == 0, which does nothing SCC-SA1018
Bug risk
Major
Autofix

With n == 0, zero instances will be replaced. To replace all instances, use a negative number, or use strings.ReplaceAll/ bytes.ReplaceAll.

It is not possible to use time.Timer.Reset()'s return value correctly SCC-SA1025
Bug risk
Critical

It is not possible to use Reset's return value correctly, as there is a race condition between draining the channel and the new timer expiring. Reset should always be invoked on stopped or expired channels. The return value exists to preserve compatibility with existing programs.

Atomic access to 64-bit variable must be 64-bit aligned SCC-SA1027
Bug risk
Major

On ARM, x86-32, and 32-bit MIPS, the caller's responsibility is to arrange for 64-bit alignment of 64-bit words accessed atomically. The first word in a variable or an allocated struct, array, or slice can be relied upon to be

Called testing.T.FailNow or testing.T.SkipNow in a goroutine SCC-SA2002
Bug risk
Major

Calling t.Testing.FailNow or t.Testing.SkipNow in a goroutine isn't allowed.

Comparing unsigned values against negative values is pointless SCC-SA4003
Bug risk
Major

Comparing unsigned values against negative values is pointless. This expression will always be true, because unsigned integers will never be less than zero.

The variable in the loop condition never changes SCC-SA4008
Bug risk
Critical

The value used in the loop condition never changes. In most cases, you might be incrementing the wrong variable.