本文整理匯總了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
}