// New() returns a new instance of Keybase object. Optionally, you can pass a string containing the path to the Keybase executable as the first argument.
funcNew(path...string)Keybase{
iflen(path)<1{
returnKeybase{path:"/usr/bin/keybase"}
}
returnKeybase{path:path[0]}
}
// Username() returns the username of the currently logged-in Keybase user.
func(kKeybase)Username()string{
cmd:=exec.Command(k.path,"status","-j")
cmdOut,err:=cmd.Output()
iferr!=nil{
return""
}
varsstatus
json.Unmarshal(cmdOut,&s)
returns.Username
}
// LoggedIn() returns true if Keybase is currently logged in, otherwise return false.
func(kKeybase)LoggedIn()bool{
cmd:=exec.Command(k.path,"status","-j")
cmdOut,err:=cmd.Output()
iferr!=nil{
returnfalse
}
varsstatus
json.Unmarshal(cmdOut,&s)
returns.LoggedIn
}
// Version() returns the version string of the client.