That editorconfig file really butchered the formatting for go

This commit is contained in:
Dane Everitt 2019-03-24 18:00:21 -07:00
parent 4bdf373ab8
commit 29de97c857
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
8 changed files with 312 additions and 271 deletions

7
go.mod
View File

@ -20,7 +20,7 @@ require (
github.com/gorilla/websocket v1.2.0 github.com/gorilla/websocket v1.2.0
github.com/hashicorp/hcl v0.0.0-20180320202055-f40e974e75af // indirect github.com/hashicorp/hcl v0.0.0-20180320202055-f40e974e75af // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/lestrrat-go/file-rotatelogs v2.1.0+incompatible github.com/lestrrat-go/file-rotatelogs v2.1.0+incompatible // indirect
github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect
github.com/magiconair/properties v1.7.6 // indirect github.com/magiconair/properties v1.7.6 // indirect
github.com/mattn/go-isatty v0.0.3 // indirect github.com/mattn/go-isatty v0.0.3 // indirect
@ -30,12 +30,13 @@ require (
github.com/pelletier/go-toml v1.1.0 // indirect github.com/pelletier/go-toml v1.1.0 // indirect
github.com/pkg/errors v0.8.0 // indirect github.com/pkg/errors v0.8.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rifflock/lfshook v0.0.0-20180227222202-bf539943797a github.com/remeh/sizedwaitgroup v0.0.0-20180822144253-5e7302b12cce // indirect
github.com/rifflock/lfshook v0.0.0-20180227222202-bf539943797a // indirect
github.com/shirou/gopsutil v0.0.0-20180227225847-5776ff9c7c5d github.com/shirou/gopsutil v0.0.0-20180227225847-5776ff9c7c5d
github.com/sirupsen/logrus v1.0.5 github.com/sirupsen/logrus v1.0.5
github.com/spf13/afero v1.0.2 // indirect github.com/spf13/afero v1.0.2 // indirect
github.com/spf13/cast v1.2.0 // indirect github.com/spf13/cast v1.2.0 // indirect
github.com/spf13/cobra v0.0.2 github.com/spf13/cobra v0.0.2 // indirect
github.com/spf13/jwalterweatherman v0.0.0-20180109140146-7c0cea34c8ec // indirect github.com/spf13/jwalterweatherman v0.0.0-20180109140146-7c0cea34c8ec // indirect
github.com/spf13/pflag v1.0.0 // indirect github.com/spf13/pflag v1.0.0 // indirect
github.com/spf13/viper v1.0.2 github.com/spf13/viper v1.0.2

2
go.sum
View File

@ -52,6 +52,8 @@ github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remeh/sizedwaitgroup v0.0.0-20180822144253-5e7302b12cce h1:aP+C+YbHZfOQlutA4p4soHi7rVUqHQdWEVMSkHfDTqY=
github.com/remeh/sizedwaitgroup v0.0.0-20180822144253-5e7302b12cce/go.mod h1:3j2R4OIe/SeS6YDhICBy22RWjJC5eNCJ1V+9+NVNYlo=
github.com/rifflock/lfshook v0.0.0-20180227222202-bf539943797a h1:zOAPcZGA4TZZv8zEI+uqbYXgyjmXtMcRVSnR0T0J2t0= github.com/rifflock/lfshook v0.0.0-20180227222202-bf539943797a h1:zOAPcZGA4TZZv8zEI+uqbYXgyjmXtMcRVSnR0T0J2t0=
github.com/rifflock/lfshook v0.0.0-20180227222202-bf539943797a/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM= github.com/rifflock/lfshook v0.0.0-20180227222202-bf539943797a/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM=
github.com/shirou/gopsutil v0.0.0-20180227225847-5776ff9c7c5d h1:TW8oufRzBs0qROjv16ll0N780gaBcgSu1TxKjwJMebM= github.com/shirou/gopsutil v0.0.0-20180227225847-5776ff9c7c5d h1:TW8oufRzBs0qROjv16ll0N780gaBcgSu1TxKjwJMebM=

View File

@ -3,7 +3,12 @@ package server
import ( import (
"github.com/pterodactyl/wings" "github.com/pterodactyl/wings"
"github.com/pterodactyl/wings/environment" "github.com/pterodactyl/wings/environment"
"github.com/remeh/sizedwaitgroup"
"go.uber.org/zap"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"io/ioutil"
"os"
"strings"
) )
// High level definition for a server instance being controlled by Wings. // High level definition for a server instance being controlled by Wings.
@ -72,6 +77,36 @@ type Allocations struct {
Mappings map[string][]int Mappings map[string][]int
} }
// Iterates over a given directory and loads all of the servers listed before returning
// them to the calling function.
func LoadDirectory(dir string) (*[]Server, error) {
wg := sizedwaitgroup.New(5)
f, err := ioutil.ReadDir(dir)
if err != nil {
return nil, err
}
zap.S().Debug("starting loop")
for _, file := range f {
if !strings.HasSuffix(file.Name(), ".yml") {
continue
}
wg.Add()
go func(file os.FileInfo) {
zap.S().Debugw("processing in parallel", zap.String("name", file.Name()))
wg.Done()
}(file)
}
wg.Wait()
zap.S().Debug("done processing files")
return nil, nil
}
// Initalizes a server using a data byte array. This will be marshaled into the // Initalizes a server using a data byte array. This will be marshaled into the
// given struct using a YAML marshaler. This will also configure the given environment // given struct using a YAML marshaler. This will also configure the given environment
// for a server. // for a server.

View File

@ -3,6 +3,7 @@ package wings
import ( import (
"flag" "flag"
"fmt" "fmt"
"github.com/pterodactyl/wings/server"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -36,6 +37,8 @@ func main() {
} }
zap.S().Infow("configuration initalized", zap.Any("config", c)) zap.S().Infow("configuration initalized", zap.Any("config", c))
server.LoadDirectory("config/servers")
} }
// Configures the global logger for Zap so that we can call it from any location // Configures the global logger for Zap so that we can call it from any location