From b7976c93c982c659aaef2743a57069e2d29bacd7 Mon Sep 17 00:00:00 2001 From: Yifan Sun Date: Mon, 2 Dec 2024 20:17:48 -0500 Subject: [PATCH] format update --- akita/cmd/component.go | 37 +++++++++++++++++++------------------ akita/cmd/root.go | 2 +- akita/entry.go | 4 ++-- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/akita/cmd/component.go b/akita/cmd/component.go index 85e15f3..5bf2122 100644 --- a/akita/cmd/component.go +++ b/akita/cmd/component.go @@ -1,19 +1,20 @@ package cmd import ( + _ "embed" "fmt" "log" "os" "os/exec" "path/filepath" "strings" - _ "embed" "github.com/spf13/cobra" ) //go:embed builderTemplate.txt var builderTemplate string + //go:embed compTemplate.txt var compTemplate string @@ -32,7 +33,7 @@ var componentCmd = &cobra.Command{ if err != nil { log.Fatalf("Error creating component: %v", err) } else { - fmt.Printf("Component '%s' created successfully!\n", componentName) + fmt.Printf("Component '%s' created successfully!\n", componentName) } errFile := generateBuilderFile(componentName) @@ -74,23 +75,23 @@ func inGitRepo() bool { // Create folder for the new component func createComponentFolder(name string) error { if _, err := os.Stat(name); err == nil { - return fmt.Errorf("folder '%s' already exists", name) - } else if !os.IsNotExist(err) { - return fmt.Errorf("%v", err) - } + return fmt.Errorf("folder '%s' already exists", name) + } else if !os.IsNotExist(err) { + return fmt.Errorf("%v", err) + } return os.MkdirAll(name, 0755) } // Create builder file for the new component func generateBuilderFile(folder string) error { - // Ensure the folder exists before proceeding + // Ensure the folder exists before proceeding _, errFind := os.Stat(folder) - if os.IsNotExist(errFind) { - return fmt.Errorf("failed to find folder %s", folder) - } else if errFind != nil { - return fmt.Errorf("%v", errFind) - } + if os.IsNotExist(errFind) { + return fmt.Errorf("failed to find folder %s", folder) + } else if errFind != nil { + return fmt.Errorf("%v", errFind) + } filePath := filepath.Join(folder, "builder.go") placeholder := "{{packageName}}" @@ -109,11 +110,11 @@ func generateBuilderFile(folder string) error { func generateCompFile(folder string) error { // Ensure the folder exists before proceeding _, errFind := os.Stat(folder) - if os.IsNotExist(errFind) { - return fmt.Errorf("failed to find folder: %s", folder) - } else if errFind != nil { - return fmt.Errorf("%v", errFind) - } + if os.IsNotExist(errFind) { + return fmt.Errorf("failed to find folder: %s", folder) + } else if errFind != nil { + return fmt.Errorf("%v", errFind) + } filePath := filepath.Join(folder, "comp.go") placeholder := "{{packageName}}" @@ -126,4 +127,4 @@ func generateCompFile(folder string) error { } return nil -} \ No newline at end of file +} diff --git a/akita/cmd/root.go b/akita/cmd/root.go index da3a410..e77781a 100644 --- a/akita/cmd/root.go +++ b/akita/cmd/root.go @@ -22,4 +22,4 @@ func Execute() { if err != nil { os.Exit(1) } -} \ No newline at end of file +} diff --git a/akita/entry.go b/akita/entry.go index d89ad6f..2bb32c0 100644 --- a/akita/entry.go +++ b/akita/entry.go @@ -3,5 +3,5 @@ package main import "github.com/sarchlab/akita/v4/akita/cmd" func main() { - cmd.Execute() -} \ No newline at end of file + cmd.Execute() +}