Fixes thanks to go vet

This commit is contained in:
nemunaire 2018-02-16 10:50:44 +01:00 committed by nemunaire
parent 4b538cdea8
commit 0ec90b14c6
4 changed files with 20 additions and 7 deletions

View File

@ -24,12 +24,9 @@ func apiHandler(f DispatchFunction) func(http.ResponseWriter, *http.Request, htt
}
log.Printf("%s \"%s %s\" [%s]\n", r.RemoteAddr, r.Method, r.URL.Path, r.UserAgent())
var ret interface{}
var err error = nil
// Read the body
if r.ContentLength < 0 || r.ContentLength > 6553600 {
http.Error(w, fmt.Sprintf("{errmsg:\"Request too large or request size unknown\"}", err), http.StatusRequestEntityTooLarge)
http.Error(w, fmt.Sprintf("{errmsg:\"Request too large or request size unknown\"}"), http.StatusRequestEntityTooLarge)
return
}
var body []byte
@ -46,6 +43,9 @@ func apiHandler(f DispatchFunction) func(http.ResponseWriter, *http.Request, htt
}
}
var ret interface{}
var err error = nil
ret, err = f(ps, body)
// Format response

View File

@ -36,7 +36,20 @@ func getSettings(_ httprouter.Params, body []byte) (interface{}, error) {
if settings.ExistsSettings(path.Join(settings.SettingsDir, settings.SettingsFile)) {
return settings.ReadSettings(path.Join(settings.SettingsDir, settings.SettingsFile))
} else {
return settings.FICSettings{"Challenge FIC", "Laboratoire SRS, ÉPITA", time.Unix(0,0), time.Unix(0,0), time.Unix(0,0), fic.FirstBlood, fic.SubmissionCostBase, false, false, false, true, true}, nil
return settings.FICSettings{
Title: "Challenge FIC",
Authors: "Laboratoire SRS, ÉPITA",
Start: time.Unix(0,0),
End: time.Unix(0,0),
Generation: time.Unix(0,0),
FirstBlood: fic.FirstBlood,
SubmissionCostBase: fic.SubmissionCostBase,
AllowRegistration: false,
DenyNameChange: false,
EnableResolutionRoute: false,
PartialValidation: true,
EnableExerciceDepend: true,
}, nil
}
}

View File

@ -82,7 +82,7 @@ func nginxGenMember() (string, error) {
for _, team := range teams {
if members, err := team.GetMembers(); err == nil {
for _, member := range members {
ret += fmt.Sprintf(" if ($remote_user = \"%s\") { set $team \"%s\"; }\n", member.Nickname, team.Id)
ret += fmt.Sprintf(" if ($remote_user = \"%s\") { set $team \"%d\"; }\n", member.Nickname, team.Id)
}
} else {
return "", err

View File

@ -113,7 +113,7 @@ func main() {
log.Fatal("Cannot have both --clouddav and --localimport defined.")
return
} else if localImporterDirectory != "" {
sync.GlobalImporter = sync.LocalImporter{localImporterDirectory, localImporterSymlink}
sync.GlobalImporter = sync.LocalImporter{Base: localImporterDirectory, Symlink: localImporterSymlink}
} else if cloudDAVBase != "" {
sync.GlobalImporter, _ = sync.NewCloudImporter(cloudDAVBase, cloudUsername, cloudPassword)
}