all: clean up minor issues found by staticcheck
Use bytes.Equal instead of comparing bytes.Compare results to zero, avoid Yoda conditions, drop a redundant zero slice capacity, use strings.ReplaceAll, build acme error strings with a strings.Builder, and lowercase an error string in ocsp. No behavior changes. Change-Id: I5d2b3fa5c241adc75e61be0f2d2d7af1eb9e8d66 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/803200 Reviewed-by: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
This commit is contained in:
committed by
Gopher Robot
parent
ff03dafdb0
commit
f2135b814c
+1
-1
@@ -734,7 +734,7 @@ func TestTLSALPN01ChallengeCert(t *testing.T) {
|
||||
if !acmeExts[0].Critical {
|
||||
t.Errorf("acmeExt.Critical = %v; want true", acmeExts[0].Critical)
|
||||
}
|
||||
if bytes.Compare(acmeExts[0].Value, extValue) != 0 {
|
||||
if !bytes.Equal(acmeExts[0].Value, extValue) {
|
||||
t.Errorf("acmeExt.Value = %v; want %v", acmeExts[0].Value, extValue)
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -114,14 +114,15 @@ type Error struct {
|
||||
}
|
||||
|
||||
func (e *Error) Error() string {
|
||||
str := fmt.Sprintf("%d %s: %s", e.StatusCode, e.ProblemType, e.Detail)
|
||||
var sb strings.Builder
|
||||
fmt.Fprintf(&sb, "%d %s: %s", e.StatusCode, e.ProblemType, e.Detail)
|
||||
if len(e.Subproblems) > 0 {
|
||||
str += fmt.Sprintf("; subproblems:")
|
||||
sb.WriteString("; subproblems:")
|
||||
for _, sp := range e.Subproblems {
|
||||
str += fmt.Sprintf("\n\t%s", sp)
|
||||
fmt.Fprintf(&sb, "\n\t%s", sp)
|
||||
}
|
||||
}
|
||||
return str
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
// AuthorizationError indicates that an authorization for an identifier
|
||||
|
||||
Reference in New Issue
Block a user