diff --git a/assets_dev.go b/assets_dev.go index 68fbc6de..569a9472 100644 --- a/assets_dev.go +++ b/assets_dev.go @@ -1,4 +1,5 @@ //go:build !release +// +build !release package main @@ -6,5 +7,5 @@ import ( "net/http" ) -// HTTP auto generated +//HTTP auto generated var HTTP http.FileSystem = http.Dir("./webgui") diff --git a/assets_release.go b/assets_release.go index b745c031..6e86e779 100644 --- a/assets_release.go +++ b/assets_release.go @@ -1,4 +1,5 @@ //go:build release +// +build release package main diff --git a/config/config.go b/config/config.go index bea82bab..9071ce93 100644 --- a/config/config.go +++ b/config/config.go @@ -117,6 +117,7 @@ func (c *Config) createEntry(name string, configDir string) *Entry { return entry } +// // Load the configuration and return loaded programs func (c *Config) Load() ([]string, error) { myini := ini.NewIni() @@ -404,8 +405,7 @@ func parseEnvFiles(s string) *map[string]string { } // GetEnv returns slice of strings with keys separated from values by single "=". An environment string example: -// -// environment = A="env 1",B="this is a test" +// environment = A="env 1",B="this is a test" func (c *Entry) GetEnv(key string) []string { value, ok := c.keyValues[key] result := make([]string, 0) @@ -426,9 +426,7 @@ func (c *Entry) GetEnv(key string) []string { } // GetEnvFromFiles returns slice of strings with keys separated from values by single "=". An envFile example: -// -// envFiles = global.env,prod.env -// +// envFiles = global.env,prod.env // cat global.env // varA=valueA func (c *Entry) GetEnvFromFiles(key string) []string { @@ -514,6 +512,7 @@ func (c *Entry) GetStringArray(key string, sep string) []string { // logSize=1GB // logSize=1KB // logSize=1024 +// func (c *Entry) GetBytes(key string, defValue int) int { v, ok := c.keyValues[key] diff --git a/config/config_test.go b/config/config_test.go index 99ef14e8..fd081071 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -2,11 +2,11 @@ package config import ( "fmt" + "supervisord/util" "io/ioutil" "os" "path/filepath" "regexp" - "supervisord/util" "testing" ) diff --git a/config/process_sort_test.go b/config/process_sort_test.go index 006df9de..45cb6821 100644 --- a/config/process_sort_test.go +++ b/config/process_sort_test.go @@ -5,7 +5,9 @@ import ( "testing" ) +// // check if program1 is before the program2 in the Entry +// func isProgramBefore(entries []*Entry, program1 string, program2 string) bool { order := 0 program1Order := -1 diff --git a/daemonize.go b/daemonize.go index e1b2ffa5..19b52fd7 100644 --- a/daemonize.go +++ b/daemonize.go @@ -1,4 +1,5 @@ //go:build !windows +// +build !windows package main diff --git a/daemonize_windows.go b/daemonize_windows.go index 960b78db..4052b150 100644 --- a/daemonize_windows.go +++ b/daemonize_windows.go @@ -1,4 +1,4 @@ -//go:build windows +// +build windows package main diff --git a/events/events_test.go b/events/events_test.go index b355d89f..608aa05d 100644 --- a/events/events_test.go +++ b/events/events_test.go @@ -126,7 +126,7 @@ func TestProcessStartingEvent(t *testing.T) { if event.GetType() != "PROCESS_STATE_STARTING" { t.Error("Fail to creating the process starting event") } - fmt.Printf("%s\n", event.GetBody()) + fmt.Printf( "%s\n", event.GetBody() ) if event.GetBody() != "processname:proc-1 groupname:group-1 from_state:STOPPED tries:0" { t.Error("Fail to encode the process starting event") } diff --git a/logger/log_unix.go b/logger/log_unix.go index 6be90077..88e95441 100644 --- a/logger/log_unix.go +++ b/logger/log_unix.go @@ -1,4 +1,4 @@ -//go:build !windows && !nacl && !plan9 +// +build !windows,!nacl,!plan9 package logger @@ -165,6 +165,7 @@ func (bs *BackendSysLogWriter) Close() error { // // - protocol, could be tcp or udp, assuming udp as default // - port, if missing, by default for tcp is 6514 and for udp - 514 +// func parseSysLogConfig(config string) (protocol string, host string, port int, err error) { fields := strings.Split(config, ":") host = "" diff --git a/logger/log_windows.go b/logger/log_windows.go index bb0510be..a7f99ada 100644 --- a/logger/log_windows.go +++ b/logger/log_windows.go @@ -1,4 +1,5 @@ //go:build windows || plan9 || nacl +// +build windows plan9 nacl package logger diff --git a/pidproxy/signal.go b/pidproxy/signal.go index 44f1caeb..1c0cc089 100644 --- a/pidproxy/signal.go +++ b/pidproxy/signal.go @@ -1,4 +1,4 @@ -//go:build !windows +// +build !windows package main diff --git a/pidproxy/signal_windows.go b/pidproxy/signal_windows.go index 86b7e4c5..23ac5ee3 100644 --- a/pidproxy/signal_windows.go +++ b/pidproxy/signal_windows.go @@ -1,4 +1,5 @@ //go:build windows +// +build windows package main diff --git a/process/command_parser.go b/process/command_parser.go index 2e923e39..ea3547ed 100644 --- a/process/command_parser.go +++ b/process/command_parser.go @@ -84,6 +84,7 @@ func parseCommand(command string) ([]string, error) { } // create command from string or []string +// func createCommand(command interface{}) (*exec.Cmd, error) { args := make([]string, 0) var err error = nil diff --git a/process/pdeathsig_linux.go b/process/pdeathsig_linux.go index 0503d38f..1530d1d2 100644 --- a/process/pdeathsig_linux.go +++ b/process/pdeathsig_linux.go @@ -1,4 +1,4 @@ -//go:build linux +// +build linux package process diff --git a/process/pdeathsig_other.go b/process/pdeathsig_other.go index 6bfd488d..f93945ad 100644 --- a/process/pdeathsig_other.go +++ b/process/pdeathsig_other.go @@ -1,4 +1,5 @@ -//go:build !linux && !windows +// +build !linux +// +build !windows package process diff --git a/process/pdeathsig_windows.go b/process/pdeathsig_windows.go index f566cefa..2e02c97e 100644 --- a/process/pdeathsig_windows.go +++ b/process/pdeathsig_windows.go @@ -1,4 +1,4 @@ -//go:build windows +// +build windows package process diff --git a/process/set_user_id.go b/process/set_user_id.go index c0b55a87..c8dc564d 100644 --- a/process/set_user_id.go +++ b/process/set_user_id.go @@ -1,13 +1,13 @@ //go:build !windows +// +build !windows package process import ( + log "github.com/sirupsen/logrus" "os/user" "strconv" "syscall" - - log "github.com/sirupsen/logrus" ) func setUserID(procAttr *syscall.SysProcAttr, uid uint32, gid uint32) { diff --git a/process/set_user_id_windows.go b/process/set_user_id_windows.go index a5b2cd15..0db3f423 100644 --- a/process/set_user_id_windows.go +++ b/process/set_user_id_windows.go @@ -1,4 +1,4 @@ -//go:build windows +// +build windows package process diff --git a/rlimit.go b/rlimit.go index 4bc574bd..f1b4a347 100644 --- a/rlimit.go +++ b/rlimit.go @@ -1,4 +1,4 @@ -//go:build !windows && !freebsd +// +build !windows,!freebsd package main diff --git a/rlimit_freebsd.go b/rlimit_freebsd.go index 80c0eede..7bed5ee3 100644 --- a/rlimit_freebsd.go +++ b/rlimit_freebsd.go @@ -1,4 +1,4 @@ -//go:build freebsd +// +build freebsd package main diff --git a/rlimit_windows.go b/rlimit_windows.go index 244b1fe0..a31d3803 100644 --- a/rlimit_windows.go +++ b/rlimit_windows.go @@ -1,4 +1,4 @@ -//go:build windows +// +build windows package main diff --git a/signals/signal.go b/signals/signal.go index 336610b4..d300bdda 100644 --- a/signals/signal.go +++ b/signals/signal.go @@ -1,4 +1,4 @@ -//go:build !windows && !darwin +// +build !windows,!darwin package signals @@ -59,10 +59,10 @@ func ToSignal(signalName string) (os.Signal, error) { // Kill sends signal to the process // // Args: +// process - the process which the signal should be sent to +// sig - the signal will be sent +// sigChildren - true if the signal needs to be sent to the children also // -// process - the process which the signal should be sent to -// sig - the signal will be sent -// sigChildren - true if the signal needs to be sent to the children also func Kill(process *os.Process, sig os.Signal, sigChildren bool) error { localSig := sig.(syscall.Signal) pid := process.Pid diff --git a/signals/signal_darwin.go b/signals/signal_darwin.go index dc41f9b3..7360137f 100644 --- a/signals/signal_darwin.go +++ b/signals/signal_darwin.go @@ -1,4 +1,4 @@ -//go:build darwin +// +build darwin package signals @@ -57,10 +57,10 @@ func ToSignal(signalName string) (os.Signal, error) { // Kill send signal to the process // // Args: +// process - the process which the signal should be sent to +// sig - the signal will be sent +// sigChildren - true if the signal needs to be sent to the children also // -// process - the process which the signal should be sent to -// sig - the signal will be sent -// sigChildren - true if the signal needs to be sent to the children also func Kill(process *os.Process, sig os.Signal, sigChildren bool) error { localSig := sig.(syscall.Signal) pid := process.Pid diff --git a/signals/signal_windows.go b/signals/signal_windows.go index 5eb08ee4..b6281f81 100644 --- a/signals/signal_windows.go +++ b/signals/signal_windows.go @@ -1,18 +1,17 @@ -//go:build windows +// +build windows package signals import ( "errors" "fmt" + log "github.com/sirupsen/logrus" "os" "os/exec" "syscall" - - log "github.com/sirupsen/logrus" ) -// convert a signal name to signal +//convert a signal name to signal func ToSignal(signalName string) (os.Signal, error) { if signalName == "HUP" { return syscall.SIGHUP, nil @@ -35,11 +34,12 @@ func ToSignal(signalName string) (os.Signal, error) { } +// // Args: +// process - the process +// sig - the signal +// sigChildren - ignore in windows system // -// process - the process -// sig - the signal -// sigChildren - ignore in windows system func Kill(process *os.Process, sig os.Signal, sigChilren bool) error { //Signal command can't kill children processes, call taskkill command to kill them cmd := exec.Command("taskkill", "/F", "/T", "/PID", fmt.Sprintf("%d", process.Pid)) diff --git a/types/process-name-sorter.go b/types/process-name-sorter.go index a769b278..97e66696 100644 --- a/types/process-name-sorter.go +++ b/types/process-name-sorter.go @@ -28,7 +28,7 @@ func (pns *ProcessNameSorter) Less(i, j int) bool { // Swap i-th program and j-th program func (pns *ProcessNameSorter) Swap(i, j int) { swapF := reflect.Swapper(pns.processes) - swapF(i, j) + swapF(i,j) } // SortProcessInfos sorts the process information by program name diff --git a/zombie_reaper.go b/zombie_reaper.go index 3e7e34cc..45e957d3 100644 --- a/zombie_reaper.go +++ b/zombie_reaper.go @@ -1,4 +1,4 @@ -//go:build !windows +// +build !windows package main diff --git a/zombie_reaper_windows.go b/zombie_reaper_windows.go index b7a214a6..87d821ea 100644 --- a/zombie_reaper_windows.go +++ b/zombie_reaper_windows.go @@ -1,4 +1,4 @@ -//go:build windows +// +build windows package main