package main // see `man 5 githooks` for details import ( "errors" "fmt" "io" "log" "os" ) func main() { for { fmt.Println(getUpdate()) } } type update struct { old, updated, ref string } func (u update) String() string { ret := fmt.Sprintf("'%s' updated from '%s' to '%s'", u.ref, u.old, u.updated) return ret } func getUpdate() update { var u update _, err := fmt.Scanf("%s %s %s\n", &u.old, &u.updated, &u.ref) if err != nil { if errors.Is(err, io.EOF) { os.Exit(0) } else { log.Fatal(err) } } return u }