Márk Sági-Kazár
2023-10-27 @ Go Budapest meetup
(Prior to 1.21)
log
packagelog
packagelog.Fatal
go-log(ger)
log(ger)
log/slog
packagepackage main
import (
"log/slog"
"os"
)
func main() {
slog.Info("Hello world!", "user", os.Getenv("USER"))
// OR
slog.Info("Hello world!", slog.String("user", os.Getenv("USER")))
}
package main
import (
"log/slog"
"os"
)
func main() {
logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
logger.Info("Hello world!", slog.String("user", os.Getenv("USER")))
}
log.Fatal
BS!