From 23aae21362b80f45b2816086be3772818d9fa19e Mon Sep 17 00:00:00 2001 From: tacheraSasi Date: Sun, 15 Dec 2024 02:04:42 +0300 Subject: [PATCH] vint init --- main.vint => _main.vint | 0 toolkit/toolkit.go | 61 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) rename main.vint => _main.vint (100%) diff --git a/main.vint b/_main.vint similarity index 100% rename from main.vint rename to _main.vint diff --git a/toolkit/toolkit.go b/toolkit/toolkit.go index 3fc3c9b..558ebda 100644 --- a/toolkit/toolkit.go +++ b/toolkit/toolkit.go @@ -197,7 +197,64 @@ func Get(pkg string){ } -func init(){ - + +// Structure for vint.json +var vintConfig = struct { + Name string `json:"name"` + Version string `json:"version"` +}{ + Name: "vint-project", + Version: "1.0.0", +} + +// Simplified VintLang code for main.vint +const sampleVintCode = `// Simple string manipulation and message printing + +// Print a greeting +print("Hello, VintLang World!") + +// Demonstrate string splitting +let phrase = "VintLang" +let letters = phrase.split("") +for letter in letters { + print(letter) +} + +// Demonstrate a simple function +let greet = func(name) { + print("Hello, " + name + "!") +} + +greet("Developer")` + +func init() { + // Creating vint.json + vintFile, err := os.Create("vint.json") + if err != nil { + fmt.Printf("Error creating vint.json: %v\n", err) + return + } + defer vintFile.Close() + + vintData, err := json.MarshalIndent(vintConfig, "", " ") + if err != nil { + fmt.Printf("Error marshalling vint.json: %v\n", err) + return + } + if _, err := vintFile.Write(vintData); err != nil { + fmt.Printf("Error writing to vint.json: %v\n", err) + } + + // Creating main.vint + mainFile, err := os.Create("main.vint") + if err != nil { + fmt.Printf("Error creating main.vint: %v\n", err) + return + } + defer mainFile.Close() + + if _, err := mainFile.WriteString(sampleVintCode); err != nil { + fmt.Printf("Error writing to main.vint: %v\n", err) + } }