Skip to content

Commit

Permalink
Update configuration file path
Browse files Browse the repository at this point in the history
  • Loading branch information
NickRTR committed Jul 30, 2023
1 parent 4ecf9e2 commit 9bf3826
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
34 changes: 17 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module github.com/NickRTR/GitHub-Automation

go 1.18

require (
github.com/google/go-github/v47 v47.1.0
golang.org/x/oauth2 v0.6.0
)

require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
)
module github.com/NickRTR/GitHub-Automation

go 1.18

require (
github.com/google/go-github/v47 v47.1.0
golang.org/x/oauth2 v0.6.0
)

require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
)
12 changes: 5 additions & 7 deletions token.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"strings"
)

var path string = ".gh-automation-config.json"

type Configuration struct {
GitHub_Token string
}
Expand Down Expand Up @@ -35,13 +37,9 @@ func GetToken() string {
return t
}

func path() string {
return fmt.Sprintf("%s/bin/GitHub-Automation.json", os.Getenv("GOROOT"))
}

func GetTokenFromConfiguration() string {
var config Configuration
configFile, err := os.Open(path())
configFile, err := os.Open(path)
if err != nil {
return ""
}
Expand All @@ -66,7 +64,7 @@ func StoreToken(token string) {
brintErr(fmt.Sprintf("An error ocurred while writing the token to configuration: %s\n", err))
}

file, err := os.Create(path())
file, err := os.Create(path)
if err != nil {
brintErr(fmt.Sprintf("An error ocurred while writing the token to configuration: %s\n", err))
}
Expand All @@ -76,7 +74,7 @@ func StoreToken(token string) {

func reset() {
brint("Resetting stored token...")
err := os.Remove(path())
err := os.Remove(path)
if err != nil {
brintErr(fmt.Sprintf("An error ocurred while resetting the stored token: %s\n", err))
}
Expand Down

0 comments on commit 9bf3826

Please sign in to comment.