Clean up linter errors
This commit is contained in:
@@ -85,6 +85,7 @@ func initControlLogFile() *os.File {
|
||||
return initializeLogFile(logFilePath, "control/portmaster-control", info.Version())
|
||||
}
|
||||
|
||||
//nolint:deadcode,unused // false positive on linux, currently used by windows only
|
||||
func logControlError(cErr error) {
|
||||
// check if error present
|
||||
if cErr == nil {
|
||||
@@ -110,6 +111,7 @@ func logControlError(cErr error) {
|
||||
errorFile.Close()
|
||||
}
|
||||
|
||||
//nolint:deadcode,unused // TODO
|
||||
func logControlStack() {
|
||||
// check logging dir
|
||||
logFileBasePath := filepath.Join(logsRoot.Path, "fstree", "control")
|
||||
@@ -126,10 +128,11 @@ func logControlStack() {
|
||||
}
|
||||
|
||||
// write error and close
|
||||
pprof.Lookup("goroutine").WriteTo(errorFile, 1)
|
||||
_ = pprof.Lookup("goroutine").WriteTo(errorFile, 2)
|
||||
errorFile.Close()
|
||||
}
|
||||
|
||||
//nolint:deadcode,unused // false positive on linux, currently used by windows only
|
||||
func runAndLogControlError(wrappedFunc func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string) error {
|
||||
return func(cmd *cobra.Command, args []string) error {
|
||||
err := wrappedFunc(cmd, args)
|
||||
|
||||
@@ -65,8 +65,8 @@ func init() {
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(&dataDir, "data", "", "set data directory")
|
||||
rootCmd.PersistentFlags().StringVar(&databaseDir, "db", "", "alias to --data (deprecated)")
|
||||
rootCmd.MarkPersistentFlagDirname("data")
|
||||
rootCmd.MarkPersistentFlagDirname("db")
|
||||
_ = rootCmd.MarkPersistentFlagDirname("data")
|
||||
_ = rootCmd.MarkPersistentFlagDirname("db")
|
||||
rootCmd.Flags().BoolVar(&showFullVersion, "version", false, "print version")
|
||||
rootCmd.Flags().BoolVar(&showShortVersion, "ver", false, "print version number only")
|
||||
}
|
||||
@@ -85,11 +85,10 @@ func main() {
|
||||
// }()
|
||||
|
||||
// catch interrupt for clean shutdown
|
||||
signalCh := make(chan os.Signal)
|
||||
signalCh := make(chan os.Signal, 2)
|
||||
signal.Notify(
|
||||
signalCh,
|
||||
os.Interrupt,
|
||||
os.Kill,
|
||||
syscall.SIGHUP,
|
||||
syscall.SIGINT,
|
||||
syscall.SIGTERM,
|
||||
|
||||
11
pmctl/run.go
11
pmctl/run.go
@@ -124,7 +124,13 @@ func run(cmd *cobra.Command, opts *Options) (err error) {
|
||||
if pid != 0 {
|
||||
return fmt.Errorf("another instance of Portmaster Core is already running: PID %d", pid)
|
||||
}
|
||||
defer deleteInstanceLock(opts.ShortIdentifier)
|
||||
defer func() {
|
||||
err := deleteInstanceLock(opts.ShortIdentifier)
|
||||
if err != nil {
|
||||
log.Printf("failed to delete instance lock: %s\n", err)
|
||||
}
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
// notify service after some time
|
||||
@@ -192,6 +198,7 @@ func run(cmd *cobra.Command, opts *Options) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// nolint:gocyclo,gocognit // TODO: simplify
|
||||
func execute(opts *Options, args []string) (cont bool, err error) {
|
||||
file, err := registry.GetFile(platform(opts.Identifier))
|
||||
if err != nil {
|
||||
@@ -236,7 +243,7 @@ func execute(opts *Options, args []string) (cont bool, err error) {
|
||||
}
|
||||
|
||||
// create command
|
||||
exc := exec.Command(file.Path(), args...)
|
||||
exc := exec.Command(file.Path(), args...) //nolint:gosec // everything is okay
|
||||
|
||||
if !runningInConsole && opts.AllowHidingWindow {
|
||||
// Windows only:
|
||||
|
||||
@@ -8,8 +8,9 @@ var (
|
||||
startupComplete = make(chan struct{}) // signal that the start procedure completed (is never closed, just signaled once)
|
||||
shuttingDown = make(chan struct{}) // signal that we are shutting down (will be closed, may not be closed directly, use initiateShutdown)
|
||||
shutdownInitiated = false // not to be used directly
|
||||
shutdownError error // may not be read or written to directly
|
||||
shutdownLock sync.Mutex
|
||||
//nolint:deadcode,unused // false positive on linux, currently used by windows only
|
||||
shutdownError error // may not be read or written to directly
|
||||
shutdownLock sync.Mutex
|
||||
)
|
||||
|
||||
func initiateShutdown(err error) {
|
||||
@@ -23,6 +24,7 @@ func initiateShutdown(err error) {
|
||||
}
|
||||
}
|
||||
|
||||
//nolint:deadcode,unused // false positive on linux, currently used by windows only
|
||||
func getShutdownError() error {
|
||||
shutdownLock.Lock()
|
||||
defer shutdownLock.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user