2 回答

TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊
dbx := sharing.New(config)
res, err := dbx.CreateSharedLinkWithSettings(arg)
if err != nil {
switch e := err.(type) {
case sharing.CreateSharedLinkWithSettingsAPIError:
fmt.Printf("%v", e.EndpointError)
// type cast to the specific error and access the field you want.
settingsError := err.(sharing.CreateSharedLinkWithSettingsAPIError)
fmt.Println(settingsError.EndpointError.SharedLinkAlreadyExists.Metadata.Url)
default:
return err
}
}

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超8個(gè)贊
答案是您可以像訪問(wèn)任何其他 golang 數(shù)據(jù)結(jié)構(gòu)一樣訪問(wèn)字段 - 沒(méi)什么特別的。
我在嘗試訪問(wèn)這些字段時(shí)遇到的錯(cuò)誤是因?yàn)檫@些字段不存在。
代碼的問(wèn)題是依賴問(wèn)題。代碼依賴于舊版本的 go-sdk,我引用了最新版本。
這個(gè)問(wèn)題很好地解釋了真正的 golang 程序員如何通過(guò)示例處理代碼中的錯(cuò)誤。我無(wú)法在網(wǎng)上找到這個(gè),所以我不會(huì)關(guān)閉這個(gè)問(wèn)題。
- 2 回答
- 0 關(guān)注
- 130 瀏覽
添加回答
舉報(bào)