From 02aa39ffd0b337edbfda995cdae50b4d34d3f409 Mon Sep 17 00:00:00 2001 From: xiantang Date: Mon, 23 Oct 2023 17:58:01 +0800 Subject: [PATCH] use embed go file --- main.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 3c91c5c1..d64bf020 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + _ "embed" "flag" "fmt" "log" @@ -20,6 +21,9 @@ var ( showVersion bool help bool cmdArgs map[string]runner.TomlInfo + + //go:embed air_example.toml + airExampleToml string ) func usage() { @@ -74,13 +78,8 @@ func GetVersionInfo() versionInfo { } func helpMessage() { - data, err := os.ReadFile("air_example.toml") - if err != nil { - log.Fatal(err) - } - var cfg runner.Config - err = toml.Unmarshal(data, &cfg) + err := toml.Unmarshal([]byte(airExampleToml), &cfg) if err != nil { log.Fatal(err) }