golang multiple-value xxx in single-value context
使用下面的程式碼的時候會出現這樣的錯誤,原因是user.Password()
返回值有兩個,但是隻能在fmt.Println
中一個位置只能使用一個值,所以會出現這樣的問題
user := url.UserPassword("username", "password")
fmt.Println("username: ", user.Username())
fmt.Println("password: ", user.Password())
fmt.Println(user.String())
解決方法
:分別定義多個變數儲存返回值,然後作為函式引數一一傳遞即可
// 建立一個Userinfo物件
user := url.UserPassword("username", "password")
fmt.Println("username: ", user.Username())
password, set := user.Password()
// 這樣傳遞!
fmt.Println("password: ", password, set)
fmt.Println(user.String())
相關文章
- Golang中context使用GolangContext
- Golang Context 包詳解GolangContext
- 深入理解golang:ContextGolangContext
- golang中的context包GolangContext
- golang Context應用舉例GolangContext
- 深入理解 Golang 之 contextGolangContext
- Golang context (上下文)是什麼GolangContext
- 2020-11-30-golang併發模式contextGolang模式Context
- golang從context原始碼領悟介面的設計GolangContext原始碼
- Golang 高效實踐之併發實踐context篇GolangContext
- 伺服器開發利器 golang context 用法詳解伺服器GolangContext
- could not connect to redis Instance at xxx.xxx.xxx.xxx:6379Redis
- Go:context.ContextGoContext
- C++ vector<std::tuple<XXX, XXX, XXX>>C++
- golang,再也不用管道了,exec.Command("bash", "-c", "ps -elf | grep xxx")Golang
- Go進階01:golang context 上下文用法詳解(比較好理解)GolangContext
- ContextContext
- go 上下文:context.ContextGoContext
- 《Lua-in-ConTeXt》02:ConTeXt 計算機Context計算機
- Linux虛擬機器配置IP時提示:determining ip information for ip xxx.xxx.xxx.xxx address is alreadyLinux虛擬機ORM
- Permission denied:user=xxx,access=WRITE,inode=xxx
- Go ContextGoContext
- context包Context
- 聊聊ContextContext
- 理解ContextContext
- 九. Go併發程式設計--context.ContextGo程式設計Context
- Context真正的實現與Context設計模式Context設計模式
- QT中error: xxx does not name a type xxx錯誤QTError
- ConTeXt 蹊徑Context
- Go:context包GoContext
- require.contextUIContext
- context包探究Context
- No instances available for XXXAI
- vue Cannot find module @/xxx/xxx.ts or its corresponding typeVue
- 搭建 docker registry 私有倉庫並解決報錯Get https://xxx.xxx.xxx.xxx:5000/v1/_ping: http: server gave HTTP respDockerHTTPServer
- Go context 介紹GoContext
- React Context那些事ReactContext
- Go語言之ContextGoContext