Created
June 14, 2021 04:37
-
-
Save chobijaeyu/92d7e5ba83bd32e4cf561f2705f6fa27 to your computer and use it in GitHub Desktop.
setRefreshToken by json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getpath() string { | |
file := os.Args[0] | |
path, err := exec.LookPath(file) | |
if err == nil { | |
path = filepath.Dir(path) | |
} | |
return path | |
} | |
func readToken() { | |
path := getpath() | |
data, err := ioutil.ReadFile(path + "/secret.json") | |
fmt.Println(path + "/secret.json") | |
fmt.Println(data) | |
if err != nil { | |
fmt.Print(err) | |
} | |
// define data structure | |
type Token struct { | |
R_refresh_token string | |
} | |
// json data | |
var obj Token | |
// unmarshall it | |
err = json.Unmarshal(data, &obj) | |
if err != nil { | |
fmt.Println("error:", err) | |
} | |
fmt.Println(obj) | |
_refresh_token = obj.R_refresh_token | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment