Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
9a5bab8524 |
1 changed files with 17 additions and 2 deletions
19
pkg.go
19
pkg.go
|
@ -38,6 +38,15 @@ type Manager struct {
|
||||||
Initialized bool
|
Initialized bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type KeyError struct {
|
||||||
|
Err error
|
||||||
|
KeyType string // PUBLIC or PRIVATE
|
||||||
|
}
|
||||||
|
|
||||||
|
func (kerr KeyError) Error() string {
|
||||||
|
return fmt.Sprintf("%s [%s]", kerr.Err.Error(), kerr.KeyType)
|
||||||
|
}
|
||||||
|
|
||||||
func NewManager(keyType KeyType, private, public string, expireDays int) (mngr Manager, err error) { // {{{
|
func NewManager(keyType KeyType, private, public string, expireDays int) (mngr Manager, err error) { // {{{
|
||||||
var errPriv, errPub error
|
var errPriv, errPub error
|
||||||
mngr.KeyType = keyType
|
mngr.KeyType = keyType
|
||||||
|
@ -61,12 +70,18 @@ func NewManager(keyType KeyType, private, public string, expireDays int) (mngr M
|
||||||
}
|
}
|
||||||
|
|
||||||
if errPriv != nil {
|
if errPriv != nil {
|
||||||
err = errPriv
|
err = KeyError{
|
||||||
|
errPriv,
|
||||||
|
"PRIVATE",
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if errPub != nil {
|
if errPub != nil {
|
||||||
err = errPub
|
err = KeyError {
|
||||||
|
errPub,
|
||||||
|
"PUBLIC",
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue