Repository: syncthing/syncthing
File: cmd/syncthing/main.go (Go)

Code before:
	} else if options.Paused {
		setPauseState(cfgWrapper, true)
	}

	appOpts := syncthing.Options{
		NoUpgrade:            options.NoUpgrade,
		ProfilerAddr:         options.DebugProfilerListen,
		ResetDeltaIdxs:       options.DebugResetDeltaIdxs,
		Verbose:              options.Verbose,
		DBRecheckInterval:    options.DebugDBRecheckInterval,
		DBIndirectGCInterval: options.DebugDBIndirectGCInterval,
	}

	if options.Audit || cfgWrapper.Options().AuditEnabled {
		l.Infoln("Auditing is enabled.")

		var ChosenAuditFile string

		// Ignore config option if command-line option is set
		if options.AuditFile != "" {
			l.Debugln("Chose the audit file from the command-line parameter.")
			ChosenAuditFile = options.AuditFile
		} else {
			l.Debugln("Chose the audit file from the config.")
			ChosenAuditFile = cfgWrapper.Options().AuditFile
		}

		appOpts.AuditWriter = auditWriter(ChosenAuditFile)
	}

	if dur, err := time.ParseDuration(os.Getenv("STRECHECKDBEVERY")); err == nil {
		appOpts.DBRecheckInterval = dur
	}
	if dur, err := time.ParseDuration(os.Getenv("STGCINDIRECTEVERY")); err == nil {
		appOpts.DBIndirectGCInterval = dur
	}

	app, err := syncthing.New(cfgWrapper, ldb, evLogger, cert, appOpts)
	if err != nil {
		l.Warnln("Failed to start Syncthing:", err)
		os.Exit(svcutil.ExitError.AsInt())
	}

	if autoUpgradePossible {
		go autoUpgrade(cfgWrapper, app, evLogger)
	}

	setupSignalHandling(app)

	if options.DebugProfileCPU {
		f, err := os.Create(fmt.Sprintf("cpu-%d.pprof", os.Getpid()))

Review comment (bug):
```suggestion
		auditFile := cfgWrapper.Options().AuditFile

		// Ignore config option if command-line option is set
		if options.AuditFile != "" {
			l.Debugln("Chose the audit file from the command-line parameter.")
			auditFile = options.AuditFile
		}
```

generally prefer short var declarations with a default plus a later override, is shorter, matches our style

Code after:
	} else if options.Paused {
		setPauseState(cfgWrapper, true)
	}

	appOpts := syncthing.Options{
		NoUpgrade:            options.NoUpgrade,
		ProfilerAddr:         options.DebugProfilerListen,
		ResetDeltaIdxs:       options.DebugResetDeltaIdxs,
		Verbose:              options.Verbose,
		DBRecheckInterval:    options.DebugDBRecheckInterval,
		DBIndirectGCInterval: options.DebugDBIndirectGCInterval,
	}

	if options.Audit || cfgWrapper.Options().AuditEnabled {
		l.Infoln("Auditing is enabled.")

		auditFile := cfgWrapper.Options().AuditFile

		// Ignore config option if command-line option is set
		if options.AuditFile != "" {
			l.Debugln("Using the audit file from the command-line parameter.")
			auditFile = options.AuditFile
		}

		appOpts.AuditWriter = auditWriter(auditFile)
	}

	if dur, err := time.ParseDuration(os.Getenv("STRECHECKDBEVERY")); err == nil {
		appOpts.DBRecheckInterval = dur
	}
	if dur, err := time.ParseDuration(os.Getenv("STGCINDIRECTEVERY")); err == nil {
		appOpts.DBIndirectGCInterval = dur
	}

	app, err := syncthing.New(cfgWrapper, ldb, evLogger, cert, appOpts)
	if err != nil {
		l.Warnln("Failed to start Syncthing:", err)
		os.Exit(svcutil.ExitError.AsInt())
	}

	if autoUpgradePossible {
		go autoUpgrade(cfgWrapper, app, evLogger)
	}

	setupSignalHandling(app)

	if options.DebugProfileCPU {
		f, err := os.Create(fmt.Sprintf("cpu-%d.pprof", os.Getpid()))
		if err != nil {
			l.Warnln("Creating profile:", err)
			os.Exit(svcutil.ExitError.AsInt())