Skip to content

Commit 6b2f6b3

Browse files
shaliernshankar13
authored andcommitted
fix golints G114 and package-comments (openservicemesh#5037)
golints addressed: 1. G114: Use of net/http serve function that has no support for setting timeouts 2. package-comments 3. removes pkg mesh and moves isValidUUID() to pkg/cli/proxy_get.go Signed-off-by: Shalier Xia <[email protected]>
1 parent af95f3e commit 6b2f6b3

File tree

19 files changed

+54
-21
lines changed

19 files changed

+54
-21
lines changed

.golangci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
run:
22
tests: true
3-
timeout: 10m
3+
timeout: 20m
44
skip-dirs:
55
- pkg/gen
66
skip-files:
@@ -35,6 +35,10 @@ issues:
3535
- revive
3636
source: ". \"github.com/openservicemesh/osm/tests/framework\""
3737
text: "dot imports"
38+
# Ignore error for package comments
39+
- linters:
40+
- revive
41+
text: "package-comments: should have a package comment"
3842
# Exclude staticcheck messages for deprecated function, variable or constant
3943
# This causes issues with package github.com/golang/protobuf/proto
4044
- linters:

demo/cmd/bookbuyer/bookbuyer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main implements the bookbuyer application
12
package main
23

34
import (
@@ -77,6 +78,7 @@ func debugServer() {
7778
}
7879
http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {})
7980
log.Info().Msgf("Web server running on port %d", *port)
81+
//#nosec G114: Use of net/http serve function that has no support for setting timeouts
8082
err = http.ListenAndServe(fmt.Sprintf(":%d", *port), router)
8183
log.Fatal().Err(err).Msgf("Failed to start HTTP server on port %d", *port)
8284
}

demo/cmd/bookstore/bookstore.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main implements the bookstore application
12
package main
23

34
import (
@@ -164,8 +165,8 @@ func main() {
164165
router.HandleFunc(h.path, h.fn).Methods(h.method)
165166
}
166167
http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {})
167-
168168
log.Info().Msgf("Bookstore running on port %d", *port)
169+
//#nosec G114: Use of net/http serve function that has no support for setting timeouts
169170
err = http.ListenAndServe(fmt.Sprintf(":%d", *port), router)
170171
log.Fatal().Err(err).Msgf("Failed to start HTTP server on port %d", *port)
171172
}

demo/cmd/bookthief/bookthief.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main implements the bookthief application
12
package main
23

34
import (
@@ -86,6 +87,7 @@ func debugServer() {
8687
}
8788
http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {})
8889
log.Info().Msgf("Bookthief running on port %d", *port)
90+
//#nosec G114: Use of net/http serve function that has no support for setting timeouts
8991
err = http.ListenAndServe(fmt.Sprintf(":%d", *port), router)
9092
log.Fatal().Err(err).Msgf("Failed to start HTTP server on port %d", *port)
9193
}

demo/cmd/bookwarehouse/bookwarehouse.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Package main implements the bookwarehouse application
2+
// This create a service which has both inbound as well as outbound service policies
3+
// i.e. bookbuyer makes a GET call to bookstore, bookstore makes a POST call to bookwarehouse
14
package main
25

36
import (
@@ -129,6 +132,7 @@ func main() {
129132
router.HandleFunc("/", restockBooks).Methods("POST")
130133
http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {})
131134
log.Info().Msgf("Starting BookWarehouse HTTP server on port %d", *port)
135+
//#nosec G114: Use of net/http serve function that has no support for setting timeouts
132136
err := http.ListenAndServe(fmt.Sprintf(":%d", *port), router)
133137
log.Fatal().Err(err).Msgf("Failed to start BookWarehouse HTTP server on port %d", *port)
134138
}

demo/cmd/bookwatcher/bookwatcher.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main implements the bookwatcher for terminal and JSON output from demo applications
12
package main
23

34
import (

demo/cmd/common/books.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package common implements shared functions and structs between various book* applications
12
package common
23

34
import (

demo/cmd/database/mysql.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Package database allows the bookwarehouse service to store
2+
// total books data into MySQL persistent storage
13
package database
24

35
import (

mockspec/generate.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Package mockspec allows the mocks to be generated consistently by doing the following:
2+
// 1. defining mockgen rules using a file to specify the parameters
3+
// 2. generating mocks the same way for each of the rules
4+
// 3. integrating checks for the mocks in the CI
15
package main
26

37
import (

pkg/auth/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package auth implements the ExtAuthConfig struct.
12
package auth
23

34
import (

0 commit comments

Comments
 (0)