From 3a738e44d60cd27bcf254e44a7be260c8c2b0ac1 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Wed, 23 Feb 2022 15:01:03 -0700 Subject: [PATCH] run gofumpt --- environment/docker/api.go | 2 +- environment/docker/environment.go | 2 +- environment/docker/power.go | 2 +- go.mod | 1 - go.sum | 2 -- router/downloader/downloader.go | 2 +- router/router_server_files.go | 3 ++- router/router_server_ws.go | 2 +- server/console_test.go | 12 ++++++------ server/events.go | 2 +- system/locker.go | 1 - system/locker_test.go | 2 +- system/rate.go | 6 +++--- system/rate_test.go | 2 +- 14 files changed, 19 insertions(+), 22 deletions(-) diff --git a/environment/docker/api.go b/environment/docker/api.go index ff18c5c..cd55f18 100644 --- a/environment/docker/api.go +++ b/environment/docker/api.go @@ -116,4 +116,4 @@ func parseErrorFromResponse(res *http.Response, body []byte) error { } return errors.Wrap(errors.New(emsg), "Error response from daemon") -} \ No newline at end of file +} diff --git a/environment/docker/environment.go b/environment/docker/environment.go index a0b7e71..f9a538c 100644 --- a/environment/docker/environment.go +++ b/environment/docker/environment.go @@ -26,7 +26,7 @@ type Metadata struct { var _ environment.ProcessEnvironment = (*Environment)(nil) type Environment struct { - mu sync.RWMutex + mu sync.RWMutex // The public identifier for this environment. In this case it is the Docker container // name that will be used for all instances created under it. diff --git a/environment/docker/power.go b/environment/docker/power.go index 3370075..d00aa1b 100644 --- a/environment/docker/power.go +++ b/environment/docker/power.go @@ -218,7 +218,7 @@ func (e *Environment) WaitForStop(ctx context.Context, duration time.Duration, t } }() - doTermination := func (s string) error { + doTermination := func(s string) error { e.log().WithField("step", s).WithField("duration", duration).Warn("container stop did not complete in time, terminating process...") return e.Terminate(ctx, os.Kill) } diff --git a/go.mod b/go.mod index db0fb9b..187b13a 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,6 @@ require ( github.com/mholt/archiver/v3 v3.5.0 github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/pkg/profile v1.6.0 github.com/pkg/sftp v1.13.2 github.com/sabhiram/go-gitignore v0.0.0-20201211210132-54b8a0bf510f github.com/spf13/cobra v1.2.1 diff --git a/go.sum b/go.sum index e3569ea..9a18060 100644 --- a/go.sum +++ b/go.sum @@ -704,8 +704,6 @@ github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/profile v1.6.0 h1:hUDfIISABYI59DyeB3OTay/HxSRwTQ8rB/H83k6r5dM= -github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pkg/sftp v1.13.2 h1:taJnKntsWgU+qae21Rx52lIwndAdKrj0mfUNQsz1z4Q= github.com/pkg/sftp v1.13.2/go.mod h1:LzqnAvaD5TWeNBsZpfKxSYn1MbjWwOsCIAFFJbpIsK8= diff --git a/router/downloader/downloader.go b/router/downloader/downloader.go index c7c7788..e283d6f 100644 --- a/router/downloader/downloader.go +++ b/router/downloader/downloader.go @@ -13,8 +13,8 @@ import ( "time" "emperror.dev/errors" - "github.com/google/uuid" "github.com/goccy/go-json" + "github.com/google/uuid" "github.com/pterodactyl/wings/server" ) diff --git a/router/router_server_files.go b/router/router_server_files.go index 976cd11..36f7387 100644 --- a/router/router_server_files.go +++ b/router/router_server_files.go @@ -3,7 +3,6 @@ package router import ( "bufio" "context" - "github.com/pterodactyl/wings/config" "io" "mime/multipart" "net/http" @@ -14,6 +13,8 @@ import ( "strconv" "strings" + "github.com/pterodactyl/wings/config" + "emperror.dev/errors" "github.com/apex/log" "github.com/gin-gonic/gin" diff --git a/router/router_server_ws.go b/router/router_server_ws.go index 5d9b6cc..77c7779 100644 --- a/router/router_server_ws.go +++ b/router/router_server_ws.go @@ -5,8 +5,8 @@ import ( "time" "github.com/gin-gonic/gin" - ws "github.com/gorilla/websocket" "github.com/goccy/go-json" + ws "github.com/gorilla/websocket" "github.com/pterodactyl/wings/router/middleware" "github.com/pterodactyl/wings/router/websocket" diff --git a/server/console_test.go b/server/console_test.go index b9ca986..9da3869 100644 --- a/server/console_test.go +++ b/server/console_test.go @@ -19,7 +19,7 @@ func TestName(t *testing.T) { }) g.It("calls strike once per time period", func() { - t := newConsoleThrottle(1, time.Millisecond * 20) + t := newConsoleThrottle(1, time.Millisecond*20) var times int t.strike = func() { @@ -53,10 +53,10 @@ func TestName(t *testing.T) { } func BenchmarkConsoleThrottle(b *testing.B) { - t := newConsoleThrottle(10, time.Millisecond * 10) + t := newConsoleThrottle(10, time.Millisecond*10) b.ReportAllocs() - for i := 0; i < b.N; i++ { - t.Allow() - } -} \ No newline at end of file + for i := 0; i < b.N; i++ { + t.Allow() + } +} diff --git a/server/events.go b/server/events.go index a7d8418..6d9af1d 100644 --- a/server/events.go +++ b/server/events.go @@ -52,4 +52,4 @@ func (s *Server) DestroyAllSinks() { for _, sink := range s.sinks { sink.Destroy() } -} \ No newline at end of file +} diff --git a/system/locker.go b/system/locker.go index b7937e5..51b8e8e 100644 --- a/system/locker.go +++ b/system/locker.go @@ -42,7 +42,6 @@ func (l *Locker) Acquire() error { return nil } - // TryAcquire will attempt to acquire a power-lock until the context provided // is canceled. func (l *Locker) TryAcquire(ctx context.Context) error { diff --git a/system/locker_test.go b/system/locker_test.go index 9250403..0e990aa 100644 --- a/system/locker_test.go +++ b/system/locker_test.go @@ -95,7 +95,7 @@ func TestPower(t *testing.T) { l.Acquire() go func() { - time.AfterFunc(time.Millisecond * 50, func() { + time.AfterFunc(time.Millisecond*50, func() { l.Release() }) }() diff --git a/system/rate.go b/system/rate.go index 270e90b..a2a1fa2 100644 --- a/system/rate.go +++ b/system/rate.go @@ -44,7 +44,7 @@ func (r *Rate) Try() bool { // Reset resets the internal state of the rate limiter back to zero. func (r *Rate) Reset() { r.mu.Lock() - r.count = 0 - r.last = time.Now() + r.count = 0 + r.last = time.Now() r.mu.Unlock() -} \ No newline at end of file +} diff --git a/system/rate_test.go b/system/rate_test.go index 3271723..9927ae6 100644 --- a/system/rate_test.go +++ b/system/rate_test.go @@ -47,7 +47,7 @@ func TestRate(t *testing.T) { g.It("resets back to zero when called", func() { r := NewRate(10, time.Second) for i := 0; i < 100; i++ { - if i % 10 == 0 { + if i%10 == 0 { r.Reset() } g.Assert(r.Try()).IsTrue()