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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀