]> Cypherpunks repositories - gostls13.git/commitdiff
all: fix some lint issues
authorRyan Leung <rleungx@gmail.com>
Tue, 23 Nov 2021 03:00:32 +0000 (03:00 +0000)
committerGopher Robot <gobot@golang.org>
Sun, 8 May 2022 17:27:54 +0000 (17:27 +0000)
Make some code more simple.

Change-Id: I801adf0dba5f6c515681345c732dbb907f945419
GitHub-Last-Rev: a505146baca00a1b3268d11d10510afa8cea6f1d
GitHub-Pull-Request: golang/go#49626
Reviewed-on: https://go-review.googlesource.com/c/go/+/364634
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/crypto/des/block.go
src/database/sql/example_cli_test.go
src/debug/plan9obj/file.go
src/go/build/constraint/expr.go
src/math/tan.go
src/net/http/cookiejar/jar.go
src/net/http/httputil/reverseproxy.go
src/runtime/metrics/description_test.go
src/testing/sub_test.go

index cc2888e2c762752a54d11e1accecc034b3ad404d..c649dee94f5826e732a0204de18a9410ecccc545 100644 (file)
@@ -248,9 +248,7 @@ func (c *desCipher) generateSubkeys(keyBytes []byte) {
 // By doing so, we can have the input blocks (four bits each), and the key blocks (six bits each) well-aligned without
 // extra shifts/rotations for alignments.
 func unpack(x uint64) uint64 {
-       var result uint64
-
-       result = ((x>>(6*1))&0xff)<<(8*0) |
+       return ((x>>(6*1))&0xff)<<(8*0) |
                ((x>>(6*3))&0xff)<<(8*1) |
                ((x>>(6*5))&0xff)<<(8*2) |
                ((x>>(6*7))&0xff)<<(8*3) |
@@ -258,6 +256,4 @@ func unpack(x uint64) uint64 {
                ((x>>(6*2))&0xff)<<(8*5) |
                ((x>>(6*4))&0xff)<<(8*6) |
                ((x>>(6*6))&0xff)<<(8*7)
-
-       return result
 }
index 8c61d755bb8458f0a1116019a84b08741406b355..1e297af02272b2e9947074f00d287ba25ad2a0c3 100644 (file)
@@ -49,10 +49,8 @@ func Example_openDBCLI() {
        signal.Notify(appSignal, os.Interrupt)
 
        go func() {
-               select {
-               case <-appSignal:
-                       stop()
-               }
+               <-appSignal
+               stop()
        }()
 
        Ping(ctx)
index 0c33fa10bb77984b483f23ff8cd3b206dafc47fe..aa0342962422a8500d0248ae68521207385eea38 100644 (file)
@@ -216,8 +216,7 @@ func walksymtab(data []byte, ptrsz int, fn func(sym) error) error {
                        p = p[4:]
                }
 
-               var typ byte
-               typ = p[0] & 0x7F
+               typ := p[0] & 0x7F
                s.typ = typ
                p = p[1:]
 
index 957eb9b5279b4f173dec48661322944fe1c23891..d64eead65491bcc86d86e234db946ecdc50207ba 100644 (file)
@@ -345,7 +345,6 @@ func (p *exprParser) lex() {
        p.i += len(tag)
        p.tok = p.s[p.pos:p.i]
        p.isTag = true
-       return
 }
 
 // IsPlusBuild reports whether the line of text is a “// +build” constraint.
index 515dd82f7310114c457eb24e5529bc5635e4ad2d..8f6e71e82b2e1383a83b9c9c9e3a3167b29d4e15 100644 (file)
@@ -67,10 +67,10 @@ var _tanP = [...]float64{
 }
 var _tanQ = [...]float64{
        1.00000000000000000000e0,
-       1.36812963470692954678e4,  //0x40cab8a5eeb36572
-       -1.32089234440210967447e6, //0xc13427bc582abc96
-       2.50083801823357915839e7,  //0x4177d98fc2ead8ef
-       -5.38695755929454629881e7, //0xc189afe03cbe5a31
+       1.36812963470692954678e4,  // 0x40cab8a5eeb36572
+       -1.32089234440210967447e6, // 0xc13427bc582abc96
+       2.50083801823357915839e7,  // 0x4177d98fc2ead8ef
+       -5.38695755929454629881e7, // 0xc189afe03cbe5a31
 }
 
 // Tan returns the tangent of the radian argument x.
index 309dfcc0e171694bd699bd9726ce6536cc9ece0c..c2393a0741f26aa2443e6c4fc4ac9df33c66c5fa 100644 (file)
@@ -303,10 +303,8 @@ func canonicalHost(host string) (string, error) {
                        return "", err
                }
        }
-       if strings.HasSuffix(host, ".") {
-               // Strip trailing dot from fully qualified domain names.
-               host = host[:len(host)-1]
-       }
+       // Strip trailing dot from fully qualified domain names.
+       host = strings.TrimSuffix(host, ".")
        encoded, err := toASCII(host)
        if err != nil {
                return "", err
index b7244134f04131ca0151e9046358eb5b2794257e..082490faaa4891968e9aab349c5274760c6bda2b 100644 (file)
@@ -622,7 +622,6 @@ func (p *ReverseProxy) handleUpgradeResponse(rw http.ResponseWriter, req *http.R
        go spc.copyToBackend(errc)
        go spc.copyFromBackend(errc)
        <-errc
-       return
 }
 
 // switchProtocolCopier exists so goroutines proxying data back and
index fd1fd46efc04da543e7ae3b8a82b5779902962e0..192c1f29ccfbf32c94729a115b85e141293b6a5a 100644 (file)
@@ -103,7 +103,7 @@ func TestDescriptionDocs(t *testing.T) {
        }
        if len(docs) > len(descriptions) {
        docsLoop:
-               for name, _ := range docs {
+               for name := range docs {
                        for _, d := range descriptions {
                                if name == d.Name {
                                        continue docsLoop
index 6a5add6f4e89f5f259d8b94ad962ffd955f612d2..6324d463cf08d9301575b515efaeeef0d7127694 100644 (file)
@@ -724,7 +724,7 @@ func TestBenchmarkReadMemStatsBeforeFirstRun(t *T) {
        var first = true
        Benchmark(func(b *B) {
                if first && (b.startAllocs == 0 || b.startBytes == 0) {
-                       panic(fmt.Sprintf("ReadMemStats not called before first run"))
+                       panic("ReadMemStats not called before first run")
                }
                first = false
        })