Exit inside non-main function RVV-A0003
Anti-pattern
Major
3 months ago2 years old
calls to log.Fatal only in main() or init() functions
 97	}
 98
 99	if minDBVersion > current.Version {
100		log.Fatal(`101Hi there, thank you for using Gogs for so long!
102However, Gogs has stopped supporting auto-migration from your previously installed version.
103But the good news is, it's very easy to fix this problem!
calls to log.Fatal only in main() or init() functions
184
185	keys, err := setupHostKeys(appDataPath, opts.ServerAlgorithms)
186	if err != nil {
187		log.Fatal("SSH: Failed to setup host keys: %v", err)188	}
189	for _, key := range keys {
190		config.AddHostKey(key)
calls to log.Fatal only in main() or init() functions
131func listen(config *ssh.ServerConfig, host string, port int) {
132	listener, err := net.Listen("tcp", host+":"+com.ToStr(port))
133	if err != nil {
134		log.Fatal("Failed to start SSH server: %v", err)135	}
136	for {
137		// Once a ServerConfig has been configured, connections can be accepted.
calls to log.Fatal only in main() or init() functions
58	if conf.Cron.RepoArchiveCleanup.Enabled {
59		entry, err = c.AddFunc("Repository archive cleanup", conf.Cron.RepoArchiveCleanup.Schedule, database.DeleteOldRepositoryArchives)
60		if err != nil {
61			log.Fatal("Cron.(repository archive cleanup): %v", err)62		}
63		if conf.Cron.RepoArchiveCleanup.RunAtStart {
64			entry.Prev = time.Now()
calls to log.Fatal only in main() or init() functions
47	if conf.Cron.CheckRepoStats.Enabled {
48		entry, err = c.AddFunc("Check repository statistics", conf.Cron.CheckRepoStats.Schedule, database.CheckRepoStats)
49		if err != nil {
50			log.Fatal("Cron.(check repository statistics): %v", err)51		}
52		if conf.Cron.CheckRepoStats.RunAtStart {
53			entry.Prev = time.Now()