Skip to content

Commit 057713b

Browse files
author
Sai Kiran Anagani
committed
change config file to be placed in home directory
1 parent 05863d7 commit 057713b

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

README.md

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

1515
```json
1616
{

digitalocean-dynamic-ip.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import (
66
"io/ioutil"
77
"log"
88
"net/http"
9-
"path/filepath"
109
"strconv"
10+
11+
homedir "github.com/mitchellh/go-homedir"
1112
)
1213

1314
func checkError(err error) {
@@ -37,10 +38,9 @@ type DOResponse struct {
3738
}
3839

3940
func main() {
40-
// load config
41-
absPath, err := filepath.Abs("./config.json")
41+
homeDirectory, err := homedir.Dir()
4242
checkError(err)
43-
getfile, err := ioutil.ReadFile(absPath)
43+
getfile, err := ioutil.ReadFile(homeDirectory + "/.digitalocean-dynamic-ip.json")
4444
checkError(err)
4545
var config ClientConfig
4646
json.Unmarshal(getfile, &config)
File renamed without changes.

0 commit comments

Comments
 (0)