dongmacheng3222 2018-05-01 02:27
浏览 14
已采纳

Go服务器在arm64上返回损坏的图像

I've written a simple HTTP image server:

go/src/demo/demo.go:

package main

import (
  "net/http"
  "github.com/gorilla/mux"
)

func main() {
  router := mux.NewRouter()
  router.HandleFunc("/foobar", func(w http.ResponseWriter, r *http.Request) {
    http.ServeFile(w, r, "/home/foobar/test.jpg")
  })

  http.ListenAndServe(":5000", router)
}

I compile it (PWD=$HOME/go/src/demo):

GOPATH=$PWD/../../ go build -o demo

And run:

./demo

Then in Chrome I open the URL. The image is corrupt -- reloading produces different corruption each time, once in a while it is fine. Larger images (~200KB) fail more often, smaller images (~20KB) fail less often.

Additional details:

go version produces go version go1.9.5 linux/arm64.

On my Macbook, this causes no issues -- only occurs on arm64 (looks like ResponseWriter does not implement flushing). I'm at a loss. Any ideas?

  • 写回答

1条回答 默认 最新

  • dongpian4954 2018-05-01 03:38
    关注

    Looks like it was an issue with the go1.9.5 release. Updated toolchain to go1.10.1 and the issue disappeared.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab中mjs用不了
  • ¥15 Ios抖音直播的时候如何添加自定义图片在直播间!
  • ¥60 riscv-pulpino总线上挂载axi从机
  • ¥15 ssh登录页面的问题
  • ¥50 关于在matlab上对曲柄摇杆机构上一点的运动学仿真
  • ¥15 jetson nano
  • ¥15 :app:debugCompileClasspath'.
  • ¥15 windows c++内嵌qt出现数据转换问题。
  • ¥15 stm32 串口通讯过程中的问题
  • ¥20 公众号如何实现点击超链接后自动发送文字