Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Apr 16, 2023
1 parent f0a91df commit 3557c23
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 16 deletions.
4 changes: 2 additions & 2 deletions browser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestIncognito(t *testing.T) {
})
}

func TestBrowserResetControlURL(t *testing.T) {
func TestBrowserResetControlURL(_ *testing.T) {
rod.New().ControlURL("test").ControlURL("")
}

Expand Down Expand Up @@ -439,7 +439,7 @@ func TestBrowserConnectFailure(t *testing.T) {
}
}

func TestBrowserPool(t *testing.T) {
func TestBrowserPool(_ *testing.T) {
pool := rod.NewBrowserPool(3)
create := func() *rod.Browser { return rod.New().MustConnect() }
b := pool.Get(create)
Expand Down
6 changes: 3 additions & 3 deletions dev_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const (
// ServeMonitor starts the monitor server.
// The reason why not to use "chrome://inspect/#devices" is one target cannot be driven by multiple controllers.
func (b *Browser) ServeMonitor(host string) string {
url, mux, close := serve(host)
u, mux, closeSvr := serve(host)
go func() {
<-b.ctx.Done()
utils.E(close())
utils.E(closeSvr())
}()

mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -89,7 +89,7 @@ func (b *Browser) ServeMonitor(host string) string {
utils.E(w.Write(p.MustScreenshot()))
})

return url
return u
}

// check method and sleep if needed
Expand Down
2 changes: 2 additions & 0 deletions lib/cdp/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestBasic(t *testing.T) {

go func() {
for range client.Event() {
utils.Noop()
}
}()

Expand Down Expand Up @@ -139,6 +140,7 @@ func TestCrash(t *testing.T) {

go func() {
for range client.Event() {
utils.Noop()
}
}()

Expand Down
1 change: 1 addition & 0 deletions lib/cdp/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func ExampleClient() {
go func() {
for range client.Event() {
// you must consume the events
utils.Noop()
}
}()

Expand Down
2 changes: 1 addition & 1 deletion lib/cdp/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Dialer interface {
// TODO: replace it with tls.Dialer once golang v1.15 is widely used.
type tlsDialer struct{}

func (d *tlsDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
func (d *tlsDialer) DialContext(_ context.Context, network, address string) (net.Conn, error) {
return tls.Dial(network, address, nil)
}

Expand Down
6 changes: 3 additions & 3 deletions lib/cdp/websocket_private_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ func (c *MockConn) RemoteAddr() net.Addr {
return nil
}

func (c *MockConn) SetDeadline(t time.Time) error {
func (c *MockConn) SetDeadline(_ time.Time) error {
return nil
}

func (c *MockConn) SetReadDeadline(t time.Time) error {
func (c *MockConn) SetReadDeadline(_ time.Time) error {
return nil
}

func (c *MockConn) SetWriteDeadline(t time.Time) error {
func (c *MockConn) SetWriteDeadline(_ time.Time) error {
return nil
}
2 changes: 2 additions & 0 deletions lib/cdp/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/go-rod/rod/lib/cdp"
"github.com/go-rod/rod/lib/launcher"
"github.com/go-rod/rod/lib/utils"
"github.com/ysmood/got"
"github.com/ysmood/gson"
)
Expand Down Expand Up @@ -81,6 +82,7 @@ func newPage(ctx context.Context, g got.G) (*cdp.Client, string) {

go func() {
for range client.Event() {
utils.Noop()
}
}()

Expand Down
4 changes: 2 additions & 2 deletions lib/docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func main() {
if master {
releaseLatest(at)
} else if ver != "" {
releaseWithVer(ver, at)
releaseWithVer(ver)
} else {
test(at)
}
Expand All @@ -45,7 +45,7 @@ func releaseLatest(at archType) {
utils.Exec("docker push", at.tag())
}

func releaseWithVer(ver string, at archType) {
func releaseWithVer(ver string) {
login()

verImageDev := registry + ":" + ver + "-dev"
Expand Down
2 changes: 1 addition & 1 deletion lib/launcher/private_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func TestBrowserDownloadErr(t *testing.T) {
g.Has(b.download(g.Context(), r.URL()).Error(), "failed to download the browser: 200")
}

func TestTestOpen(t *testing.T) {
func TestTestOpen(_ *testing.T) {
openExec = func(name string, arg ...string) *exec.Cmd {
cmd := exec.Command("not-exists")
cmd.Process = &os.Process{}
Expand Down
2 changes: 1 addition & 1 deletion lib/proto/a_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ proto.Client = &Client{}
var _ proto.Sessionable = &Client{}
var _ proto.Contextable = &Client{}

func (c *Client) Call(ctx context.Context, sessionID, methodName string, params interface{}) (res []byte, err error) {
func (c *Client) Call(_ context.Context, sessionID, methodName string, params interface{}) (res []byte, err error) {
c.sessionID = sessionID
c.methodName = methodName
c.params = params
Expand Down
3 changes: 3 additions & 0 deletions lib/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ var TestEnvs = map[string]string{
// InContainer will be true if is inside container environment, such as docker
var InContainer = FileExists("/.dockerenv") || FileExists("/.containerenv")

// Noop does nothing
func Noop() {}

// Logger interface
type Logger interface {
// Same as fmt.Printf
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestOutputJSONErr(t *testing.T) {
})
}

func TestSleep(t *testing.T) {
func TestSleep(_ *testing.T) {
utils.Sleep(0.01)
}

Expand All @@ -148,7 +148,7 @@ func TestAll(t *testing.T) {
utils.All(c, c, c)()
}

func TestPause(t *testing.T) {
func TestPause(_ *testing.T) {
go utils.Pause()
}

Expand Down
2 changes: 2 additions & 0 deletions page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ func TestPageEvent(t *testing.T) {

go func() {
for range p.Event() {
utils.Noop()
}
}()
p.MustClose()
Expand All @@ -579,6 +580,7 @@ func TestPageStopEventAfterDetach(t *testing.T) {
p.MustClose()
}()
for range p.Event() {
utils.Noop()
}
}

Expand Down
2 changes: 1 addition & 1 deletion setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ type MockReader struct {
err error
}

func (mr *MockReader) Read(p []byte) (n int, err error) {
func (mr *MockReader) Read(_ []byte) (n int, err error) {
return 0, mr.err
}

Expand Down

0 comments on commit 3557c23

Please sign in to comment.