我對Go語言相當陌生,並且很難實現以下目標:我收到一個base64字符串(基本上是一個編碼圖像),需要將其轉換爲服務器上的二進制表單。將base64請求正文編碼爲二進制
func addOrUpdateUserBase64(w http.ResponseWriter, r *http.Request, params martini.Params) {
c := appengine.NewContext(r)
sDec, _ := b64.StdEncoding.DecodeString(r.Body)
...
這是行不通的,因爲DecodeString需要一個字符串...如何將request.Body轉換爲字符串?任何提示都非常感謝!
工作,我覺得這是應該做的正確方法它。我會用'new(bytes.Buffer)'來表示樣式;) – fabrizioM
哇!這是純粹的迷人。你能否推薦任何與io.Readers/Writers有特別關係的進一步閱讀,以及它們在Go中的使用情況? – Ralf
[this](http://blog.golang.org/gif-decoder-exercise-in-go-interfaces)和[this](http://blog.golang.org/json-rpc-tale-of-界面)和[this]的開始部分(http://blog.golang.org/laws-of-reflection)和[this](http://golang.org/doc/effective_go.html#interfaces_and_types)。 – kostix