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#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作