📌

Goa v3 で go:embed を利用する試行錯誤

に公開
4

Discussion

chezgichezgi

thanks ikawaha,
when embedding web files its encoding was set to plain-text.
if you add mime detection based on file extension, it works.
in design:

			Response(func() {
				Header("length:Content-Length")
				Header("encoding:Content-Type")
			})

and in code:

	return &static.FileResultType{
		Length:   fi.Size(),
		Encoding: mime.TypeByExtension(filepath.Ext(fpath)),
	}, f, nil
ikawahaikawaha

Thank you for commenting on an important point!
I have corrected them.

HikaruooHikaruoo

SkipResponseBodyEncodeDecode()の使用ポイントや、embed.FSを活用したディレクトリ指定の詳細な実装が大変参考になります。

アセット埋め込みを活用することで、運用面でも配布が楽になる利点が明確に伝わってきました。このような取り組みは、リリースフローをシンプル化したい開発者にとって有益だと感じます。ありがとうございます。