func appDataPath() string {
//use the full path to the app when in a snap package, but
//for local development, assume that the app is run from bin/arch
dir := os.Getenv("SNAP_APP_PATH")
fmt.Println("app path ENV is " + dir)
if dir == "" {
fmt.Println("no snap app data path, guessing ../../")
dir = "../../"
}
return dir
}
func initConfig() {
//create a Config instance and fill it from the yaml file
dir := appDataPath()
For what it is worth, if any cares, here is a smaller code listing that produces the error
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"time"
)
import "gopkg.in/yaml.v2"
var config Config
type Config struct {
Duration string
}
func appDataPath() string { "SNAP_APP_ PATH")
//use the full path to the app when in a snap package, but
//for local development, assume that the app is run from bin/arch
dir := os.Getenv(
fmt.Println("app path ENV is " + dir)
if dir == "" {
fmt.Println("no snap app data path, guessing ../../")
dir = "../../"
}
return dir
}
func initConfig() {
//create a Config instance and fill it from the yaml file
dir := appDataPath()
yamlfilename := filepath.Join(dir, "cnf", "config.yaml") "Looking for yaml file at: " + yamlfilename)
fmt.Println(
yamlFile, err := ioutil. ReadFile( yamlfilename)
err = yaml.Unmarshal( yamlFile, &config) "failed to read config") "config created")
if err != nil {
fmt.Println(
log.Fatal(err)
} else {
fmt.Println(
}
}
func main() { "Uploader started") ion(config. Duration) "failed to read seconds from config") "tick")
fmt.Println(
initConfig()
s, err := time.ParseDurat
if err != nil {
fmt.Println(
log.Fatal(err)
}
ticker := time.NewTicker(s)
for _ = range ticker.C {
fmt.Println(
}