From 459cd35ec092fdb48e1825ccd01fb630a77474bf Mon Sep 17 00:00:00 2001
From: cui fliter
+ The vet
tool now reports calls to
+ append
that pass
+ no values to be appended to the slice, such as slice = append(slice)
.
+ Such a statement has no effect, and experience has shown that is nearly always a mistake.
+
time.Since
+ The vet tool now reports a non-deferred call to
+ time.Since(t)
within a defer
statement.
+ This is equivalent to calling time.Now().Sub(t)
before the defer
statement,
+ not when the deferred function is called. In nearly all cases, the correct code
+ requires deferring the time.Since
call. For example:
+
+t := time.Now() +defer log.Println(time.Since(t)) // non-deferred call to time.Since +tmp := time.Since(t); defer log.Println(tmp) // equivalent to the previous defer + +defer func() { + log.Println(time.Since(t)) // a correctly deferred call to time.Since +}() ++ +
log/slog
calls
+ The vet tool now reports invalid arguments in calls to functions and methods
+ in the structured logging package, log/slog
,
+ that accept alternating key/value pairs.
+ It reports calls where an argument in a key position is neither a
+ string
nor a slog.Attr
, and where a final key is missing its value.
+
-- 2.48.1