[feature] Updated go.mod to Go v1.18 and extended log func
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
316323587d
commit
39ed417398
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"git.pbiernat.dev/golang/rest-api-prototype/internal/app/database"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
@ -22,7 +21,7 @@ const (
|
||||
|
||||
func main() {
|
||||
if config.ErrLoadingEnvs != nil {
|
||||
log.Fatalln("Error loading .env file")
|
||||
app.Panicf("Error loading .env file")
|
||||
}
|
||||
|
||||
httpAddr := net.JoinHostPort(config.GetEnv("SERVER_IP", defHttpIp), config.GetEnv("SERVER_PORT", defHttpPort))
|
||||
@ -30,7 +29,7 @@ func main() {
|
||||
|
||||
dbc, err := database.Connect(dbConnStr)
|
||||
if err != nil {
|
||||
log.Panicf("Unable to connect to database: %v\n", err)
|
||||
app.Panicf("Unable to connect to database: %v\n", err)
|
||||
}
|
||||
|
||||
env := &handler.Env{httpAddr, dbc}
|
||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
||||
module git.pbiernat.dev/golang/rest-api-prototype
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible
|
||||
|
16
internal/app/log.go
Normal file
16
internal/app/log.go
Normal file
@ -0,0 +1,16 @@
|
||||
package app
|
||||
|
||||
import "log"
|
||||
|
||||
func Panic(v ...any) {
|
||||
log.Panicln(Name + ":", v)
|
||||
}
|
||||
|
||||
func Panicf(format string, v ...any) {
|
||||
log.Panicf(Name + ": " + format, v...)
|
||||
}
|
||||
|
||||
func Panicln(v ...any) {
|
||||
v = append([]any{Name + ":"}, v...)
|
||||
log.Panicln(v...)
|
||||
}
|
@ -15,6 +15,8 @@ import (
|
||||
"git.pbiernat.dev/golang/rest-api-prototype/internal/app/handler"
|
||||
)
|
||||
|
||||
const Name = "REST API Service"
|
||||
|
||||
type Server struct {
|
||||
*http.Server
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user