Skip to content

Commit 3b27855

Browse files
chore: statically build sql commands
1 parent 6a858f4 commit 3b27855

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: sql/create_db.sql renamed to core/create_db.sql

File renamed without changes.

Diff for: core/data_structures.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package core
22

33
import (
4+
_ "embed"
45
"fmt"
56
"log"
67
"os"
@@ -11,6 +12,9 @@ import (
1112
"github.com/charmbracelet/bubbles/textinput"
1213
)
1314

15+
//go:embed create_db.sql
16+
var createSqlCommands []byte
17+
1418
// A singular form input control
1519
type FormInput struct {
1620
Name string
@@ -243,10 +247,6 @@ type Config struct {
243247

244248
// Constructor for the Config struct
245249
func NewConfig(data string, root string, dbFileName string) *Config {
246-
sqlCommands, err := os.ReadFile("sql/create_db.sql")
247-
if err != nil {
248-
log.Fatalf("Failed to read SQL commands: %v", err)
249-
}
250250
rootExists := true
251251
if _, err := os.Stat(root); os.IsNotExist(err) {
252252
rootExists = false
@@ -258,7 +258,7 @@ func NewConfig(data string, root string, dbFileName string) *Config {
258258
Data: data,
259259
Root: root,
260260
DbFileName: dbFileName,
261-
CreateSqlCommands: sqlCommands,
261+
CreateSqlCommands: createSqlCommands,
262262
}
263263
return &config
264264
}

0 commit comments

Comments
 (0)