1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Package www holds the web pages' templates and assets, and the version
// string, compiled into the binary so that it runs from any directory.
//
// The embed lives here, inside www/, because go:embed cannot reach into a
// parent directory.
package www

import (
	"embed"
	"strings"
)

//go:embed *.tmpl assets version.txt
var FS embed.FS

// Version is the contents of version.txt, which the build overwrites with the
// release (see package.nix), trimmed of surrounding whitespace; e.g. "v1.2.3".
var Version = func() string {
	b, err := FS.ReadFile("version.txt")
	if err != nil {
		panic(err)
	}
	return strings.TrimSpace(string(b))
}()