forked from gittuf/gittuf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
37 lines (30 loc) · 1.04 KB
/
main.go
File metadata and controls
37 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright The gittuf Authors
// SPDX-License-Identifier: Apache-2.0
package main
import (
"fmt"
"os"
"runtime/debug"
"github.com/gittuf/gittuf/internal/cmd/profile"
"github.com/gittuf/gittuf/internal/cmd/root"
)
func main() {
defer func() {
if err := profile.StopProfiling(); err != nil {
fmt.Fprintf(os.Stderr, "unexpected profiling error: %s\n", err.Error())
}
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "unexpected error: %s\n\n", fmt.Sprint(r))
debug.PrintStack()
fmt.Fprintln(os.Stderr, "\nPlease consider filing a bug on https://github.com/gittuf/gittuf/issues with the stack trace and steps to reproduce this state. Thanks!")
os.Exit(1) // this is the last possible deferred function to run
}
}()
rootCmd := root.New()
if err := rootCmd.Execute(); err != nil {
// We can ignore the linter here (deferred functions are not executed
// when os.Exit is invoked) because if we do have an error, we don't
// have a panic, which is what the deferred function is looking for.
os.Exit(1) //nolint:gocritic
}
}