本文整理汇总了Golang中github.com/apex/log.Interface.Fatal方法的典型用法代码示例。如果您正苦于以下问题:Golang Interface.Fatal方法的具体用法?Golang Interface.Fatal怎么用?Golang Interface.Fatal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/apex/log.Interface
的用法示例。
在下文中一共展示了Interface.Fatal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetAppID
// GetAppID returns the AppID that must be set in the command options or config
func GetAppID(ctx log.Interface) string {
appID := viper.GetString("app-id")
if appID == "" {
appData := readData(appFilename)
id, ok := appData[idKey].(string)
if !ok {
ctx.Fatal("Invalid appID in config file.")
}
appID = id
}
if appID == "" {
ctx.Fatal("Missing AppID. You should select an application to use with \"ttnctl applications select\"")
}
return appID
}
示例2: getStoredToken
func getStoredToken(ctx log.Interface) *oauth2.Token {
tokenCache := GetTokenCache()
data, err := tokenCache.Get(tokenName())
if err != nil {
ctx.WithError(err).Fatal("Could not read stored token")
}
if data == nil {
ctx.Fatal("No account information found. Please login with ttnctl user login [access code]")
}
token := &oauth2.Token{}
err = json.Unmarshal(data, token)
if err != nil {
ctx.Fatal("Account information invalid. Please login with ttnctl user login [access code]")
}
return token
}
示例3: GetAppEUI
// GetAppEUI returns the AppEUI that must be set in the command options or config
func GetAppEUI(ctx log.Interface) types.AppEUI {
appEUIString := viper.GetString("app-eui")
if appEUIString == "" {
appData := readData(appFilename)
eui, ok := appData[euiKey].(string)
if !ok {
ctx.Fatal("Invalid AppEUI in config file")
}
appEUIString = eui
}
if appEUIString == "" {
ctx.Fatal("Missing AppEUI. You should select an application to use with \"ttnctl applications select\"")
}
eui, err := types.ParseAppEUI(appEUIString)
if err != nil {
ctx.WithError(err).Fatal("Invalid AppEUI")
}
return eui
}