CobraV2/serial_read/path_unix.go
foglar 97d57b139b Added directories for saving logs
- slightly edited .ino files
- documentation added
- now it will save the logs in special directories on any os
2024-01-29 16:54:26 +01:00

39 lines
588 B
Go

//go:build !windows
// +build !windows
package main
import (
"fmt"
"github.com/mitchellh/go-homedir"
"log"
"os"
)
var (
HOME string
PATH string
)
// Check if the directory exists
func init() {
var err error
HOME, err = homedir.Dir()
if err != nil {
log.Fatal(err)
}
PATH = HOME + "/.config/serial-monitor/"
if _, err := os.Stat(PATH); os.IsNotExist(err) {
// Directory does not exist, create it
err := os.MkdirAll(PATH, os.ModePerm)
if err != nil {
fmt.Println("Error creating directory:", err)
} else {
fmt.Println("Directory created:", PATH)
}
}
}