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 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突