package main import ( "fmt" "log" "os" "strings" ) func main() { // Specify the file path // Log environment variables (for debugging purposes) logEnvironment() fileP := []string{"lbconfig_", ".txt"} //t := time.Now() //filePath := strings.Join(fileP, t.Local().Format("2006-01-02_15:04:05")) filestr := strings.Join(fileP, "test") filePath := "/loxilb/" + filestr f, err := os.Create(filePath) if err != nil { fmt.Printf("Can't create dump file\n") os.Exit(1) } defer f.Close() // Log success message log.Println("File created successfully:", filePath) // Optionally, write some content to the file content := []byte("This is a test file.") _, err = f.Write(content) if err != nil { // Log error if writing to the file fails log.Printf("Failed to write to file: %s (error: %v)", filePath, err) return } // Log success message after writing log.Println("Content written to file successfully") } // logEnvironment logs all the environment variables (for debugging purposes) func logEnvironment() { for _, e := range os.Environ() { log.Println(e) } }