github.com/jpreese/tflint@v0.19.2-0.20200908152133-b01686250fb6/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 "path" 7 "runtime" 8 "strings" 9 10 colorable "github.com/mattn/go-colorable" 11 "github.com/terraform-linters/tflint/cmd" 12 ) 13 14 func main() { 15 cli := cmd.NewCLI(colorable.NewColorable(os.Stdout), colorable.NewColorable(os.Stderr)) 16 17 defer func() { 18 if r := recover(); r != nil { 19 fmt.Fprintf(os.Stderr, "Panic: %v\n", r) 20 for depth := 0; ; depth++ { 21 pc, src, line, ok := runtime.Caller(depth) 22 if !ok { 23 break 24 } 25 fmt.Fprintf(os.Stderr, " -> %d: %s: %s(%d)\n", depth, runtime.FuncForPC(pc).Name(), strings.Replace(src, path.Dir(src), "", 1), line) 26 } 27 fmt.Fprintln(os.Stderr, ` 28 TFLint crashed... :( 29 Please attach an output log, describe the situation and version that occurred and post an issue to https://github.com/terraform-linters/tflint/issues`) 30 os.Exit(cmd.ExitCodeError) 31 } 32 }() 33 34 os.Exit(cli.Run(os.Args)) 35 }