Home

horcrux @42e6acfcba92156df1dbc062a90b5b61daf067eb - refs - log -
-
https://git.jolheiser.com/horcrux.git
Split your source across forges
horcrux / config.go
- raw -
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main

import (
	"encoding/json"
	"time"
)

type Config struct {
	Key      string
	Interval Duration
	Storage  string
	Repos    []RepoConfig
}

type RepoConfig struct {
	Name   string
	Source string
	Dest   []string
}

type Duration time.Duration

func (d *Duration) UnmarshalJSON(b []byte) error {
	var s string
	if err := json.Unmarshal(b, &s); err != nil {
		return err
	}
	dur, err := time.ParseDuration(s)
	if err != nil {
		return err
	}
	*d = Duration(dur)
	return nil
}