ci: add staticcheck job
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
cătălin 2022-06-28 15:09:00 +02:00
commit e7a9ddc460
No known key found for this signature in database
GPG key ID: C378F1E869F05A95
3 changed files with 27 additions and 21 deletions

20
main.go
View file

@ -12,10 +12,10 @@ var SFU_FILES_DIR string = getEnvvar("SFU_FILES_DIR")
var SFU_PORT string = getEnvvar("SFU_PORT")
func getEnvvar(envvar_name string) string {
Info.Printf("getting envvar %v", envvar_name)
Info.Printf("getting envvar %v\n", envvar_name)
envvar_value, isSet := os.LookupEnv(envvar_name)
if !isSet {
Error.Println(fmt.Sprintf("%v is not set", envvar_name))
Error.Printf("%v is not set\n", envvar_name)
os.Exit(1)
}
return envvar_value
@ -33,9 +33,9 @@ func emptyArray(s []string) []string {
func routeFiles(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path
Info.Println(fmt.Sprintf("received %v on %v", r.Method, path))
Info.Printf("received %v on %v", r.Method, path)
paths := emptyArray(strings.Split(path, "/"))
Info.Println(fmt.Sprintf("paths %v", paths))
Info.Printf("paths %v\n", paths)
switch len(paths) {
case 1:
switch r.Method {
@ -45,8 +45,8 @@ func routeFiles(w http.ResponseWriter, r *http.Request) {
uploadFile(w, r)
default:
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
Warning.Println(fmt.Sprintf("%v not allowed", r.Method))
Error.Println(fmt.Sprintf("will return %v", http.StatusMethodNotAllowed))
Warning.Printf("%v not allowed\n", r.Method)
Error.Printf("will return %v\n", http.StatusMethodNotAllowed)
}
return
case 2:
@ -57,8 +57,8 @@ func routeFiles(w http.ResponseWriter, r *http.Request) {
deleteFile(w, r, paths[1])
default:
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
Warning.Println(fmt.Sprintf("%v not allowed", r.Method))
Error.Println(fmt.Sprintf("will return %v", http.StatusMethodNotAllowed))
Warning.Printf("%v not allowed\n", r.Method)
Error.Printf("will return %v\n", http.StatusMethodNotAllowed)
}
default:
http.Error(w, "Not found", http.StatusNotFound)
@ -87,10 +87,10 @@ func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", route)
port := fmt.Sprintf(":%v", SFU_PORT)
Info.Println(fmt.Sprintf("running SFU on port %v", port))
Info.Printf("running SFU on port %v\n", port)
err := http.ListenAndServe(port, mux)
if err != nil {
Error.Println(fmt.Sprintf("%v port may not be available", port))
Error.Printf("%v port may not be available\n", port)
os.Exit(1)
}
}