Skip to content

Commit ea630f8

Browse files
committed
Use embed instead of rice
For embedding assets, we've traditionally used the rice module. However, this module always tries to read data from a zip file appended to the binary (in an `init` function, no less) based off of reading data from the ELF, Mach-O, or PE sections, and on Go 1.19, this segfaults. These modules don't seem to be maintained even to the extent of accepting pull requests, so it's not likely that this will be fixed. Instead, let's use the Go 1.16 embed functionality, which can embed arbitrary files into the binary simply and automatically. Replace the rice.Box code with an embed.FS and look up paths with the full relative path. Bump the go.mod to 1.16 to indicate that users may need to upgrade. Remove the imports for rice, which is no longer needed.
1 parent 54fdf7a commit ea630f8

File tree

5 files changed

+10
-124
lines changed

5 files changed

+10
-124
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ require (
99
github.com/kardianos/osext v0.0.0-20150317202929-efacde031546 // indirect
1010
)
1111

12-
go 1.11
12+
go 1.16

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"crypto/tls"
5+
"embed"
56
"fmt"
67
"net"
78
"os"
@@ -20,6 +21,9 @@ var (
2021
logger = NewKVLogger(os.Stdout)
2122
)
2223

24+
//go:embed all:mgmt
25+
var embedded embed.FS
26+
2327
// tcpKeepAliveListener sets TCP keep-alive timeouts on accepted
2428
// connections. It's used by ListenAndServe and ListenAndServeTLS so
2529
// dead TCP connections (e.g. closing laptop mid-download) eventually

mgmt-css.rice-box.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)