1
0

change config file to be placed in home directory

This commit is contained in:
Sai Kiran Anagani 2017-09-18 18:50:07 +05:30
parent 05863d7a6d
commit 057713b443
3 changed files with 5 additions and 5 deletions

View File

@ -10,7 +10,7 @@ Requires that the record already exists in DigitalOcean's DNS.
```bash
git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git
```
create a file config.json and place it same directory as this script and add the following json
create a file ".digitalocean-dynamic-ip.json"(dot prefix to hide the file) and place it user home directory and add the following json
```json
{

View File

@ -6,8 +6,9 @@ import (
"io/ioutil"
"log"
"net/http"
"path/filepath"
"strconv"
homedir "github.com/mitchellh/go-homedir"
)
func checkError(err error) {
@ -37,10 +38,9 @@ type DOResponse struct {
}
func main() {
// load config
absPath, err := filepath.Abs("./config.json")
homeDirectory, err := homedir.Dir()
checkError(err)
getfile, err := ioutil.ReadFile(absPath)
getfile, err := ioutil.ReadFile(homeDirectory + "/.digitalocean-dynamic-ip.json")
checkError(err)
var config ClientConfig
json.Unmarshal(getfile, &config)