Check for missing values after append. appends
An analyzer of go vet, which runs with go test. Run it alone with go vet -appends.
- Code
appends
Source: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
The lint rules of Go, with what each one finds. This page has 195 cards.
appendsAn analyzer of go vet, which runs with go test. Run it alone with go vet -appends.
appendsSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
asmdeclAn analyzer of go vet, which runs with go test. Run it alone with go vet -asmdecl.
asmdeclSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
assignAn analyzer of go vet, which runs with go test. Run it alone with go vet -assign.
assignSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
atomicAn analyzer of go vet, which runs with go test. Run it alone with go vet -atomic.
atomicSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
boolsAn analyzer of go vet, which runs with go test. Run it alone with go vet -bools.
boolsSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
buildtagAn analyzer of go vet, which runs with go test. Run it alone with go vet -buildtag.
buildtagSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
cgocallAn analyzer of go vet, which runs with go test. Run it alone with go vet -cgocall.
cgocallSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
compositesAn analyzer of go vet, which runs with go test. Run it alone with go vet -composites.
compositesSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
copylocksAn analyzer of go vet, which runs with go test. Run it alone with go vet -copylocks.
copylocksSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
defersAn analyzer of go vet, which runs with go test. Run it alone with go vet -defers.
defersSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
directiveAn analyzer of go vet, which runs with go test. Run it alone with go vet -directive.
directiveSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
errorsasAn analyzer of go vet, which runs with go test. Run it alone with go vet -errorsas.
errorsasSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
framepointerAn analyzer of go vet, which runs with go test. Run it alone with go vet -framepointer.
framepointerSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
hostportAn analyzer of go vet, which runs with go test. Run it alone with go vet -hostport.
hostportSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
httpresponseAn analyzer of go vet, which runs with go test. Run it alone with go vet -httpresponse.
httpresponseSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
ifaceassertAn analyzer of go vet, which runs with go test. Run it alone with go vet -ifaceassert.
ifaceassertSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
loopclosureAn analyzer of go vet, which runs with go test. Run it alone with go vet -loopclosure.
loopclosureSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
lostcancelAn analyzer of go vet, which runs with go test. Run it alone with go vet -lostcancel.
lostcancelSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
nilfuncAn analyzer of go vet, which runs with go test. Run it alone with go vet -nilfunc.
nilfuncSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
printfAn analyzer of go vet, which runs with go test. Run it alone with go vet -printf.
printfSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
QF1001De Morgan’s laws allow negated boolean expressions to be rewritten by exchanging && and || and negating their operands. For example, !(a && b) can be written as !a || !b. It is in Staticcheck since 2021.1. It is in the quickfix group of checks.
QF1001Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
QF1002An untagged switch that compares a single variable against a series of values can be replaced with a tagged switch. It is in Staticcheck since 2021.1. It is in the quickfix group of checks.
QF1002Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
QF1003A series of if/else-if checks comparing the same variable against values can be replaced with a tagged switch. It is in Staticcheck since 2021.1. It is in the quickfix group of checks.
QF1003Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
QF1004The strings and bytes packages provide functions for replacing or splitting all occurrences without an explicit count. Calls to Replace with a count of -1 can use ReplaceAll instead; similarly, SplitN and SplitAfterN can use Split and SplitAfter. It is in Staticcheck since 2021.1. It is in the quickfix group of checks.
QF1004Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
QF1005Some uses of math.Pow can be simplified to basic multiplication. It is in Staticcheck since 2021.1. It is in the quickfix group of checks.
QF1005Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
QF1006An unconditional loop that begins with an if statement whose only action is to break can instead use the negated condition as its loop condition. This makes the loop’s termination condition visible in the loop header and removes a level of nesting. It is in Staticcheck since 2021.1. It is in the quickfix group of checks.
QF1006Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
QF1007A boolean variable initialized to false and immediately set to true under a condition can be initialized with that condition directly. The reverse pattern, starting with true and conditionally setting false, can use the negated condition. It is in Staticcheck since 2021.1. It is in the quickfix group of checks.
QF1007Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
QF1008Go promotes the fields and methods of embedded fields to the containing struct. When this allows the same field or method to be accessed directly, the explicit embedded field can be omitted to make selectors less verbose. It is in Staticcheck since 2021.1. It is in the quickfix group of checks.
QF1008Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
QF1009Comparing time.Time values with == compares all their fields, including their locations and monotonic clock readings. Two values can therefore represent the same instant yet compare unequal. It is in Staticcheck since 2021.1. It is in the quickfix group of checks.
QF1009Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
QF1010Functions such as fmt.Println and log.Print print a []byte as a list of numeric byte values. If the slice contains text and the intent is to print that text, converting the slice to a string produces the desired output. It is in Staticcheck since 2021.1. It is in the quickfix group of checks.
QF1010Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
QF1011A local variable’s type can be inferred from its initial value. When this inferred type is identical to the explicitly declared type, the explicit type can be omitted to make the declaration shorter without changing its meaning. It is in Staticcheck since 2021.1. It is in the quickfix group of checks.
QF1011Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
QF1012When writing formatted output to an io.Writer, fmt.Fprint, fmt.Fprintf, and fmt.Fprintln can format and write in one call. This is more direct than passing the result of fmt.Sprint, fmt.Sprintf, or fmt.Sprintln to WriteString or converting it to []byte for Write, and avoids constructing an intermediate string. It is in Staticcheck since 2022.1. It is in the quickfix group of checks.
QF1012Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1000Select statements with a single case can be replaced with a simple send or receive. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1000Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1001Use copy() for copying elements from one slice to another. For arrays of identical size, you can use simple assignment. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1001Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1002A boolean expression can be used directly instead of comparing it with true or false. Use the expression itself, or its negation with !, to express the same condition without the redundant comparison. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1002Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1003When only checking whether a string or byte slice contains a value, use Contains instead of comparing the result of Index with zero or -1. This expresses the intent directly, without an explicit comparison of positions. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1003Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1004When comparing byte slices for equality, use bytes.Equal instead of comparing the result of bytes.Compare with zero. bytes.Equal makes the intent clear, while bytes.Compare is useful when the ordering of the slices matters. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1004Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1005In many cases, assigning to the blank identifier is unnecessary. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1005Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1006For infinite loops, using for { ... } is the most idiomatic choice. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1006Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1007Raw string literals use backticks instead of quotation marks and do not support any escape sequences. This means that the backslash can be used freely, without the need of escaping. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1007Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1008An if statement that returns true when a condition holds, followed by a return of false, can be replaced with a single return of the condition. If the return values are reversed, return the negated condition instead. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1008Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1009The len function is defined for all slices, maps, and channels, even nil ones, which have a length of zero. It is not necessary to check for nil before checking that their length is not zero. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1009Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1010When slicing, the second index defaults to the length of the value, making s[n:len(s)] and s[n:] equivalent. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1010Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1011When two slices have the same type, a loop that only appends elements from one to the other can be replaced with a single call to append. Use append(x, y...) to append all elements of y to x, making the concatenation explicit without a loop. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1011Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1012The time.Since helper has the same effect as using time.Now().Sub(x) but is easier to read. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1012Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1016Two struct types with identical fields can be converted between each other. In older versions of Go, the fields had to have identical struct tags. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1016Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1017Instead of using strings.HasPrefix and manual slicing, use the strings.TrimPrefix function. If the string doesn’t start with the prefix, the original string will be returned. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1017Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1018copy() permits using the same source and destination slice, even with overlapping ranges. This makes it ideal for sliding elements in a slice. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1018Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1019The make function has default values for the length and capacity arguments. For channels, the length defaults to zero, and for slices, the capacity defaults to the length. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1019Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1020A successful type assertion implies that the original interface value is not nil. When checking the boolean result of a type assertion, an additional nil check on that interface is redundant. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1020Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1021A variable declaration immediately followed by its initial assignment can be combined into a declaration with an initializer, as long as the initializer does not refer to the variable itself. This keeps the variable and its initial value together while preserving any explicit type needed for the declaration. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1021Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1023Functions that have no return value do not need a return statement as the final statement of the function. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1023Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1024The time.Until helper has the same effect as using x.Sub(time.Now()) but is easier to read. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1024Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1025In many instances, there are easier and more efficient ways of getting a value’s string representation. Whenever a value’s underlying type is a string already, or the type has a String method, they should be used directly. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1025Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1028The fmt.Errorf function formats a message and returns it as an error. Use it instead of wrapping a call to fmt.Sprintf in errors.New to construct an error with a formatted message in a single call. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1028Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1029Ranging over a string will yield byte offsets and runes. If the offset isn’t used, this is functionally equivalent to converting the string to a slice of runes and ranging over that. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1029Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1030bytes.Buffer has both a String and a Bytes method. It is almost never necessary to use string(buf.Bytes()) or []byte(buf.String()) – simply use the other method. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1030Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1031You can use range on nil slices and maps, the loop will simply never execute. This makes an additional nil check around the loop unnecessary. It is in Staticcheck since 2017.1. It is in the simple group of checks.
S1031Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1032The sort.Ints, sort.Float64s and sort.Strings functions are easier to read than sort.Sort(sort.IntSlice(x)), sort.Sort(sort.Float64Slice(x)) and sort.Sort(sort.StringSlice(x)). It is in Staticcheck since 2019.1. It is in the simple group of checks.
S1032Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1033Calling delete on a nil map is a no-op. It is in Staticcheck since 2019.2. It is in the simple group of checks.
S1033Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1034A type switch can bind the matched value to a variable using switch v := x.(type). Within a case that lists a single type, the variable has that type. It is in Staticcheck since 2019.2. It is in the simple group of checks.
S1034Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1035The methods on net/http.Header, namely Add, Del, Get and Set, already canonicalize the given header name. It is in Staticcheck since 2020.1. It is in the simple group of checks.
S1035Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1036When accessing a map key that doesn’t exist yet, one receives a zero value. Often, the zero value is a suitable value, for example when using append or doing integer math. It is in Staticcheck since 2020.1. It is in the simple group of checks.
S1036Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1037Using a select statement with a single case receiving from the result of time.After is a very elaborate way of sleeping that can much simpler be expressed with a simple call to time.Sleep. It is in Staticcheck since 2020.1. It is in the simple group of checks.
S1037Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1038Instead of using fmt.Print(fmt.Sprintf(...)), one can use fmt.Printf(...). It is in Staticcheck since 2020.1. It is in the simple group of checks.
S1038Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1039Calling fmt.Sprint with a single string argument is unnecessary and identical to using the string directly. It is in Staticcheck since 2020.1. It is in the simple group of checks.
S1039Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
S1040The type assertion x.(SomeInterface), when x already has type SomeInterface, can only fail if x is nil. Usually, this is left-over code from when x had a different type and you can safely delete the type assertion. It is in Staticcheck since 2021.1. It is in the simple group of checks.
S1040Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1000The regular expression cannot be parsed by the regexp package. Functions such as regexp.Compile return an error for this pattern, while regexp.MustCompile panics. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1000Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1001The Parse methods in text/template and html/template return an error for malformed template syntax, such as an unclosed action or an unexpected character in an action. Correct the template’s actions and delimiters before attempting to execute it. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1001Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1002time.Parse requires a layout string that uses Go’s reference time: Mon Jan 2 15:04:05 MST 2006. The layout must represent this date and time exactly. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1002Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1003The encoding/binary package can only serialize types with known sizes. This precludes the use of the int and uint types, as their sizes differ on different architectures. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1003Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1004The time.Sleep function takes a time.Duration as its only argument. Durations are expressed in nanoseconds. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1004Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1005os/exec runs programs directly (using variants of the fork and exec system calls on Unix systems). This shouldn’t be confused with running a command in a shell. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1005Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1006Using fmt.Printf with a dynamic first argument can lead to unexpected output. The first argument is a format string, where certain character combinations have special meaning. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1006Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1007The URL contains a syntax error that causes net/url.Parse to return an error. Correct the URL’s syntax, using url.PathEscape or url.QueryEscape for individual path segments or query values that require escaping. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1007Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1008Keys in http.Header maps are canonical, meaning they follow a specific combination of uppercase and lowercase letters. Methods such as http.Header.Add and http.Header.Del convert inputs into this canonical form before manipulating the map. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1008Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1010If n >= 0, the function returns at most n matches/submatches. To return all results, specify a negative number. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1010Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1011Functions in the strings package that process Unicode code points expect UTF-8-encoded strings. Invalid UTF-8 byte sequences are interpreted as Unicode replacement characters, not as the original bytes. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1011Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1012The context package prohibits the use of a nil context. If no parent context is available, a new context should be used, e.g. context.TODO or context.Background. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1012Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1013The first argument to Seek is a byte offset. The second argument selects the origin for that offset: io.SeekStart, io.SeekCurrent, or io.SeekEnd. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1013Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1014Functions such as encoding/json.Unmarshal and (*encoding/json.Decoder).Decode require a pointer to the value that should be populated. Passing a non-pointer value results in the function returning an error at runtime, as it cannot modify the target value. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1014Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1015Before Go 1.23, time.Tickers had to be closed to be able to be garbage collected. Since time.Tick doesn’t make it possible to close the underlying ticker, using it repeatedly would leak memory. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1015Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1016Not all signals can be intercepted by a process. Specifically, on UNIX-like systems, the syscall.SIGKILL and syscall.SIGSTOP signals are never passed to the process, but instead handled directly by the kernel. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1016Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1017The os/signal package uses non-blocking channel sends when delivering signals. If the receiving end of the channel isn’t ready and the channel is either unbuffered or full, the signal will be dropped. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1017Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1018With n == 0, zero instances will be replaced. To replace all instances, use a negative number, or use strings.ReplaceAll. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1018Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1019An API marked with a Deprecated: documentation comment is no longer recommended for use. Its deprecation message explains the reason and may suggest a replacement. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1019Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1020Functions such as net.Listen, net.ListenTCP, and similar, expect a valid network address in the form of host:port. The host, the port, or both, can be omitted, e.g. localhost:8080, :8080 or : are valid host:port pairs. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1020Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1021A 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. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1021Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1023Write must not modify the slice data, even temporarily. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1023Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1024The strings.TrimLeft and strings.TrimRight functions take cutsets, not prefixes. A cutset is treated as a set of characters to remove from a string. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA1024Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1025When using pre-Go 1.23 timer semantics, draining a timer’s channel based on Reset’s return value is racy: the new timer may expire before the channel is drained, causing the new notification to be consumed instead of the old one. Stop the timer and, if necessary, drain its channel before calling Reset. It is in Staticcheck since 2019.1. It is in the staticcheck group of checks.
SA1025Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1026JSON and XML encoders cannot represent values such as channels and functions, including those in exported struct fields or collection elements. XML encoding also does not support maps. It is in Staticcheck since 2019.2. It is in the staticcheck group of checks.
SA1026Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1027On ARM, x86-32, and 32-bit MIPS, it is the caller’s responsibility to arrange for 64-bit alignment of 64-bit words accessed atomically. The first word in a variable or in an allocated struct, array, or slice can be relied upon to be 64-bit aligned. It is in Staticcheck since 2019.2. It is in the staticcheck group of checks.
SA1027Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1028The first argument of sort.Slice must be a slice. It is in Staticcheck since 2020.1. It is in the staticcheck group of checks.
SA1028Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1029The provided key must be comparable and should not be of type string or any other built-in type to avoid collisions between packages using context. Users of WithValue should define their own types for keys. It is in Staticcheck since 2020.1. It is in the staticcheck group of checks.
SA1029Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1030This check validates the format, number base and bit size arguments of the various parsing and formatting functions in strconv. It is in Staticcheck since 2021.1. It is in the staticcheck group of checks.
SA1030Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1031In an encoding function of the form Encode(dst, src), dst and src were found to reference the same memory. This can result in src bytes being overwritten before they are read, when the encoder writes more than one byte per src byte. It is in Staticcheck since 2024.1. It is in the staticcheck group of checks.
SA1031Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA1032The first argument of the function errors.Is is the error that we have and the second argument is the error we’re trying to match against. It is in Staticcheck since 2024.1. It is in the staticcheck group of checks.
SA1032Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA2000(*sync.WaitGroup).Add must be called before starting the goroutine it is meant to wait for. Calling Add inside the goroutine creates a race condition between the call to Add and the call to Wait. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA2000Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA2001Empty critical sections of the kind. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA2001Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA2002Methods such as FailNow and SkipNow, including Fatal, Fatalf, Skip, and Skipf, stop the calling goroutine using runtime.Goexit. They must be called from the goroutine running the test or benchmark, not from a goroutine it starts. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA2002Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA2003Deferring a call to Lock immediately after locking is almost always a typo. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA2003Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA3000Test executables (and in turn go test) exit with a non-zero status code if any tests failed. When specifying your own TestMain function, it is your responsibility to arrange for this, by calling os.Exit with the correct code. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA3000Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA3001The testing package dynamically sets b.N to improve the reliability of benchmarks and uses it in computations to determine the duration of a single operation. Benchmark code must not alter b.N as this would falsify results. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA3001Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4000Using the same expression on both sides of an operator often indicates a copy-and-paste error or a typo. For example, x == x compares a value with itself, and x - x subtracts it from itself. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4000Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4001Combining address-taking and pointer dereferencing does not create a copy of the pointed-to value. In particular, &*p still points to the same object as p. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4001Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4003An integer’s type limits the range of values it can hold. Comparisons against these limits can be redundant or indicate an incorrect boundary check. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4003Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4004An unconditional break or return prevents a loop from running more than once, even if it appears to search or process multiple elements. Check whether the exit should depend on a condition, or whether a continue was intended. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4004Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4005A method with a value receiver operates on a copy of the receiver. Assigning to a field of that copy has no effect on the caller’s value. It is in Staticcheck since 2021.1. It is in the staticcheck group of checks.
SA4005Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4006A value assigned to a variable may go unused even if the variable is read later, because a later assignment can overwrite the value first. This may hide a missing step, such as checking an error before reusing err. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4006Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4008It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4008Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4009Overwriting a parameter before reading it discards the value supplied by the caller. This may indicate an accidental assignment or a parameter being used as a local variable. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4009Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4010Calls to append produce a new slice value. When the result of append is assigned to a variable that is never subsequently read, the append operation may have an unintended effect. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4010Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4011An unlabeled break terminates the innermost for, switch, or select statement. Inside a switch or select nested in a loop, it does not terminate the loop. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4011Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4012NaN is not equal to any value, including itself. Equality and ordering comparisons with NaN are always false, while != comparisons are always true. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4012Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4013Unlike languages that use double negation to convert a value to a boolean, Go only allows ! on boolean operands. Applying it twice restores the original value. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4013Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4014In an if/else if chain without side effects in its conditions, a repeated condition cannot become true after it was already false. The later branch is therefore unreachable. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4014Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4015Converting an integer to a floating-point value does not produce a fractional part, NaN, or infinity. Applying math.Ceil, math.Floor, or math.Trunc to that value leaves it unchanged, and math.IsNaN and math.IsInf return false. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4015Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4016The expressions x | 0 and x ^ 0 leave x unchanged, while x & 0 always produces zero. These operations may indicate a typo or an incorrectly defined bit mask. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4016Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4017Some functions return a result instead of modifying their arguments or other program state. Discarding all return values of such a function leaves its result unused. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4017Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4018Assigning a variable to itself preserves its existing value and is usually redundant. It may indicate a typo in either the source or the destination of an assignment, especially in a list of similar field assignments. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4018Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4019Multiple legacy +build lines are combined with a logical AND. Repeating the same constraint, even with its space-separated terms in a different order, does not further restrict when the file is built. Remove the duplicate line, or correct it if a different constraint was intended. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA4019Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4020In a type switch like the following. It is in Staticcheck since 2019.2. It is in the staticcheck group of checks.
SA4020Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4021Calling append with only a slice and no elements returns the slice unchanged. It does not copy its elements or allocate a new backing array. It is in Staticcheck since 2019.2. It is in the staticcheck group of checks.
SA4021Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4022Code such as if &x == nil is meaningless, because taking the address of a variable always yields a non-nil pointer. It is in Staticcheck since 2020.1. It is in the staticcheck group of checks.
SA4022Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4023Under the covers, interfaces are implemented as two elements, a type T and a value V. V is a concrete value such as an int, struct or pointer, never an interface itself, and has type T. For instance, if we store the int value 3 in an interface, the resulting interface value has, schematically, (T=int, V=3). It is in Staticcheck since 2020.2. It is in the staticcheck group of checks.
SA4023Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4024Return values of the len and cap builtins cannot be negative. It is in Staticcheck since 2021.1. It is in the staticcheck group of checks.
SA4024Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4025When dividing two integer constants, the result will also be an integer. Thus, a division such as 2 / 3 results in 0. It is in Staticcheck since 2021.1. It is in the staticcheck group of checks.
SA4025Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4026In IEEE 754 floating point math, zero has a sign and can be positive or negative. This can be useful in certain numerical code. It is in Staticcheck since 2021.1. It is in the staticcheck group of checks.
SA4026Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4027(*net/url.URL).Query parses the current value of net/url.URL.RawQuery and returns it as a map of type net/url.Values. Subsequent changes to this map will not affect the URL unless the map gets encoded and assigned to the URL’s RawQuery. It is in Staticcheck since 2021.1. It is in the staticcheck group of checks.
SA4027Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4028The remainder of integer division by one is always zero, regardless of the dividend. If a remainder was intended, check whether the divisor should be a different value. It is in Staticcheck since 2022.1. It is in the staticcheck group of checks.
SA4028Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4029sort.Float64Slice, sort.IntSlice, and sort.StringSlice are types, not functions. Doing x = sort.StringSlice(x) does nothing, especially not sort any values. It is in Staticcheck since 2022.1. It is in the staticcheck group of checks.
SA4029Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4030Functions in the math/rand package that accept upper limits, such as Intn, generate random numbers in the half-open interval [0,n). In other words, the generated numbers will be >= 0 and < n – they don’t include n. rand.Intn(1) therefore doesn’t generate 0 or 1, it always generates 0. It is in Staticcheck since 2022.1. It is in the staticcheck group of checks.
SA4030Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4031Values created by new or make, as well as function declarations and function literals, are non-nil. Checking such a value against nil cannot distinguish success from failure. It is in Staticcheck since 2022.1. It is in the staticcheck group of checks.
SA4031Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA4032A file’s build constraints, including those implied by its name, limit the platforms on which its code can run. Comparing runtime.GOOS or runtime.GOARCH with a value excluded by those constraints makes an equality check always false and an inequality check always true. It is in Staticcheck since 2024.1. It is in the staticcheck group of checks.
SA4032Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA5000The zero value of a map is nil. Reading from a nil map is safe, but assigning to an element panics. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA5000Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA5001If a call to acquire a resource fails, the returned resource may be nil or otherwise unusable. Deferring Close before handling the error can cause a panic instead of the intended error handling. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA5001Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA5002An empty loop with no condition runs continuously, consuming CPU without doing useful work. An empty loop whose condition only reads ordinary variables cannot safely wait for another goroutine to change them: unsynchronized reads and writes constitute a data race. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA5002Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA5003Defers 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. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA5003Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA5004A select with a default branch does not block when none of its channel operations can proceed. In an unconditional loop, an empty default branch therefore causes the loop to spin, consuming CPU while waiting for work. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA5004Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA5005A finalizer is a function associated with an object that runs when the garbage collector is ready to collect said object, that is when the object is no longer referenced by anything. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA5005Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA5007A function that calls itself recursively needs to have an exit condition. Otherwise it will recurse forever, until the system runs out of memory. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA5007Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA5008Malformed struct tags, duplicate keys, and invalid JSON or XML options can cause reflection-based packages to ignore the intended settings or report errors. Use the conventional space-separated key:"value" syntax and ensure that each option is supported by the package reading the tag and is appropriate for the field’s type. It is in Staticcheck since 2019.2. It is in the staticcheck group of checks.
SA5008Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA5009Formatting functions such as fmt.Printf and fmt.Sprintf require the format string to agree with the number and types of the arguments. Malformed formats, invalid argument indices, and mismatched arguments produce diagnostic text such as %!d(string=...) instead of the intended output. It is in Staticcheck since 2019.2. It is in the staticcheck group of checks.
SA5009Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA5010Some type assertions can be statically proven to be impossible. This is the case when the method sets of both arguments of the type assertion conflict with each other, for example by containing the same method with different signatures. It is in Staticcheck since 2020.1. It is in the staticcheck group of checks.
SA5010Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA5012Some functions that take slices as parameters expect the slices to have an even number of elements. Often, these functions treat elements in a slice as pairs. It is in Staticcheck since 2020.2. It is in the staticcheck group of checks.
SA5012Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA6000The package-level functions regexp.Match, regexp.MatchString, and regexp.MatchReader compile the regular expression on every call. When the pattern is constant, calling these functions in a loop repeatedly performs the same compilation work. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA6000Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA6001Map keys must be comparable, which precludes the use of byte slices. This usually leads to using string keys and converting byte slices to strings. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA6001Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA6002A sync.Pool is used to avoid unnecessary allocations and reduce the amount of work the garbage collector has to do. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA6002Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA6003You may want to loop over the runes in a string. Instead of converting the string to a slice of runes and looping over that, you can loop over the string itself. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA6003Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA6005Converting two strings to the same case and comparing them like so. It is in Staticcheck since 2019.2. It is in the staticcheck group of checks.
SA6005Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA6006Using io.WriteString to write a slice of bytes, as in. It is in Staticcheck since 2024.1. It is in the staticcheck group of checks.
SA6006Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA9001Deferred calls run when the surrounding function returns, not at the end of each loop iteration. A range loop over a channel may keep receiving indefinitely if the channel is never closed, leaving deferred cleanup pending and allowing resources to accumulate. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA9001Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA9002File permissions are conventionally written in octal, with one digit for each of the owner, group, and other permission sets. A literal such as 644 is decimal in Go and sets different permission bits than intended, potentially granting unwanted access. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA9002Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA9003An empty branch often indicates missing code, such as an error that was checked but never handled. Implement the intended behavior, or simplify the conditional if the branch deliberately does nothing. It is in Staticcheck since 2017.1. It is in the staticcheck group of checks.
SA9003Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA9004In a constant declaration such as the following. It is in Staticcheck since 2019.1. It is in the staticcheck group of checks.
SA9004Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA9005The encoding/json and encoding/xml packages only operate on exported fields in structs, not unexported ones. It is usually an error to try to (un)marshal structs that only consist of unexported fields. It is in Staticcheck since 2019.2. It is in the staticcheck group of checks.
SA9005Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA9006Bit shifting a value past its size will always clear the value. It is in Staticcheck since 2020.2. It is in the staticcheck group of checks.
SA9006Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA9007It is virtually never correct to delete system directories such as /tmp or the user’s home directory. However, it can be fairly easy to do by mistake, for example by mistakenly using os.TempDir instead of ioutil.TempDir, or by forgetting to add a suffix to the result of os.UserHomeDir. It is in Staticcheck since 2022.1. It is in the staticcheck group of checks.
SA9007Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA9008When declaring variables as part of an if statement (like in if foo := ...; foo {), the same variables will also be in the scope of the else branch. This means that in the following example. It is in Staticcheck since 2022.1. It is in the staticcheck group of checks.
SA9008Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA9009A potential Go compiler directive was found, but is ineffectual as it begins with whitespace. It is in Staticcheck since 2024.1. It is in the staticcheck group of checks.
SA9009Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
SA9010If you have a function such as. It is in Staticcheck since 2026.2. It is in the staticcheck group of checks.
SA9010Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
shiftAn analyzer of go vet, which runs with go test. Run it alone with go vet -shift.
shiftSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
sigchanyzerAn analyzer of go vet, which runs with go test. Run it alone with go vet -sigchanyzer.
sigchanyzerSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
slogAn analyzer of go vet, which runs with go test. Run it alone with go vet -slog.
slogSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
ST1000Packages must have a package comment that is formatted according to the guidelines laid out in https://go.dev/wiki/CodeReviewComments#package-comments. It is in Staticcheck since 2019.1. It is in the stylecheck group of checks.
ST1000Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1001Dot imports that aren’t in external test packages are discouraged. It is in Staticcheck since 2019.1. It is in the stylecheck group of checks.
ST1001Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1003Identifiers, such as variable and package names, follow certain rules. It is in Staticcheck since 2019.1. It is in the stylecheck group of checks.
ST1003Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1005Error strings follow a set of guidelines to ensure uniformity and good composability. It is in Staticcheck since 2019.1. It is in the stylecheck group of checks.
ST1005Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1006Quoting Go Code Review Comments. It is in Staticcheck since 2019.1. It is in the stylecheck group of checks.
ST1006Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1008It is in Staticcheck since 2019.1. It is in the stylecheck group of checks.
ST1008Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1011time.Duration values represent an amount of time, which is represented as a count of nanoseconds. An expression like 5 * time.Microsecond yields the value 5000. It is in Staticcheck since 2019.1. It is in the stylecheck group of checks.
ST1011Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1012Error variables that are part of an API should be called errFoo or ErrFoo. It is in Staticcheck since 2019.1. It is in the stylecheck group of checks.
ST1012Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1013HTTP has a tremendous number of status codes. While some of those are well known (200, 400, 404, 500), most of them are not. It is in Staticcheck since 2019.1. It is in the stylecheck group of checks.
ST1013Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1015Placing the default case at the beginning or end of a switch makes it easier to find and keeps the explicit cases together. An exception is when a fallthrough statement makes the position of the default case significant. It is in Staticcheck since 2019.1. It is in the stylecheck group of checks.
ST1015Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1016Methods on the same type should use the same receiver name, including both pointer and value receivers. Consistent names make it easier to recognize the receiver when reading different methods of the type. It is in Staticcheck since 2019.1. It is in the stylecheck group of checks.
ST1016Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1017Yoda conditions are conditions of the kind if 42 == x, where the literal is on the left side of the comparison. These are a common idiom in languages in which assignment is an expression, to avoid bugs of the kind if (x = 42). It is in Staticcheck since 2019.2. It is in the stylecheck group of checks.
ST1017Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1018Invisible format and control characters in string literals can be hard to spot and can make the source code misleading. If such a character is intentional, make it visible with an escape sequence in an interpreted string literal; otherwise, remove it. It is in Staticcheck since 2019.2. It is in the stylecheck group of checks.
ST1018Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1019Go allows importing the same package multiple times, as long as different import aliases are being used. That is, the following bit of code is valid. It is in Staticcheck since 2020.1. It is in the stylecheck group of checks.
ST1019Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1020Doc comments work best as complete sentences, which allow a wide variety of automated presentations. The first sentence should be a one-sentence summary that starts with the name being declared. It is in Staticcheck since 2020.1. It is in the stylecheck group of checks.
ST1020Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1021Doc comments work best as complete sentences, which allow a wide variety of automated presentations. The first sentence should be a one-sentence summary that starts with the name being declared. It is in Staticcheck since 2020.1. It is in the stylecheck group of checks.
ST1021Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1022Doc comments work best as complete sentences, which allow a wide variety of automated presentations. The first sentence should be a one-sentence summary that starts with the name being declared. It is in Staticcheck since 2020.1. It is in the stylecheck group of checks.
ST1022Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
ST1023In a local variable declaration, omit an explicit type when the initializer already determines the same type. For example, use var x = f() instead of var x T = f() when f returns T. Keep the explicit type when omitting it would change the variable’s type, such as when assigning a concrete value to an interface variable. It is in Staticcheck since 2021.1. It is in the stylecheck group of checks.
ST1023Source: staticcheck.dev. JSON record. This entry is a card. Help write this page.
stdmethodsAn analyzer of go vet, which runs with go test. Run it alone with go vet -stdmethods.
stdmethodsSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
stdversionAn analyzer of go vet, which runs with go test. Run it alone with go vet -stdversion.
stdversionSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
stringintconvAn analyzer of go vet, which runs with go test. Run it alone with go vet -stringintconv.
stringintconvSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
structtagAn analyzer of go vet, which runs with go test. Run it alone with go vet -structtag.
structtagSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
testinggoroutineAn analyzer of go vet, which runs with go test. Run it alone with go vet -testinggoroutine.
testinggoroutineSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
testsAn analyzer of go vet, which runs with go test. Run it alone with go vet -tests.
testsSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
timeformatAn analyzer of go vet, which runs with go test. Run it alone with go vet -timeformat.
timeformatSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
unmarshalAn analyzer of go vet, which runs with go test. Run it alone with go vet -unmarshal.
unmarshalSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
unreachableAn analyzer of go vet, which runs with go test. Run it alone with go vet -unreachable.
unreachableSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
unsafeptrAn analyzer of go vet, which runs with go test. Run it alone with go vet -unsafeptr.
unsafeptrSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
unusedresultAn analyzer of go vet, which runs with go test. Run it alone with go vet -unusedresult.
unusedresultSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.
waitgroupAn analyzer of go vet, which runs with go test. Run it alone with go vet -waitgroup.
waitgroupSource: pkg.go.dev, pkg.go.dev. JSON record. This entry is a card. Help write this page.