Compare commits

..

2 commits

Author SHA1 Message Date
Chandler Swift 2c078285b8
Embed template for single-binary deploys 2023-09-29 21:14:20 -05:00
Chandler Swift c97321beae
Add Makefile dependencies 2023-09-29 21:13:35 -05:00
3 changed files with 6 additions and 2 deletions

View file

@ -1,2 +1,2 @@
minecraft-site: minecraft-site: minecraft-site.go index.html go.mod go.sum
go build -tags netgo -ldflags '-extldflags "-static"' go build -tags netgo -ldflags '-extldflags "-static"'

View file

@ -2,6 +2,7 @@ package main
import ( import (
"crypto/tls" "crypto/tls"
_ "embed"
"encoding/json" "encoding/json"
"fmt" "fmt"
"html/template" "html/template"
@ -35,6 +36,9 @@ type pageData struct {
Servers []server Servers []server
} }
//go:embed index.html
var indexhtml string
func main() { func main() {
// Parse config file // Parse config file
@ -63,7 +67,7 @@ func main() {
// Set up templates // Set up templates
fmt.Print("Parsing templates...\n") fmt.Print("Parsing templates...\n")
t, err := template.ParseFiles("templates/index.html") t, err := template.New("").Parse(indexhtml)
if err != nil { if err != nil {
log.Fatalf("Error parsing HTML template: %v\n", err) log.Fatalf("Error parsing HTML template: %v\n", err)
} }