github.com/abolfazlbeh/zhycan@v0.0.0-20230819144214-24cf38237387/cmd/cmd_main/commands/templates/main.gotmpl (about)

     1  /*
     2  Create By Zhycan Framework
     3  
     4  Copyright © {{.Year}}
     5  Project: {{.ProjectName}}
     6  File: `main.go` --> {{ .Time.Format .TimeFormat }} by {{.CreatorUserName}}
     7  ------------------------------
     8  */
     9  package main
    10  
    11  import (
    12      "fmt"
    13      "{{.ProjectName}}/commands"
    14      "github.com/abolfazlbeh/zhycan/pkg/config"
    15      "github.com/abolfazlbeh/zhycan/pkg/logger"
    16      "time"
    17  )
    18  
    19  /*
    20  The main file of the project
    21  */
    22  func main() {
    23      fmt.Println("{{.ProjectName}} is Started ...")
    24  
    25      // config module attributes
    26      baseConfigPath := "."           // the base path for the parameters. by default it's the current directory
    27      initialConfigMode := "dev"            // it can be override by environment value --> the value can be `dev` and `prod` and whatever you want
    28      configPrefix := "{{.ProjectName}}"    // this will be used in reading value from environment with this prefix
    29  
    30      err := config.InitializeManager(baseConfigPath, initialConfigMode, configPrefix)
    31      if err != nil {
    32          fmt.Println(err)
    33          return
    34      }
    35  
    36      // Testing the logger module works properly
    37      logger.Log(logger.NewLogObject(
    38          logger.INFO, "main.go", logger.FuncMaintenanceType, time.Now().UTC(), "Logger Module Works Like A Charm ...", nil))
    39  
    40      // Execute the provided command
    41      commands.Execute()
    42  }