POST translate string -> vain.Vcs
This commit is contained in:
parent
c2597fd41a
commit
2b96b761d1
18
vain.go
18
vain.go
@ -3,7 +3,10 @@
|
||||
// The executable, cmd/ysvd, is located in the respective subdirectory.
|
||||
package vain
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type vcs int
|
||||
|
||||
@ -62,3 +65,16 @@ func (p Package) String() string {
|
||||
p.Repo,
|
||||
)
|
||||
}
|
||||
|
||||
func (p *Package) UnmarshalJSON(b []byte) (err error) {
|
||||
pkg := struct {
|
||||
Vcs string
|
||||
Repo string
|
||||
}{}
|
||||
err = json.Unmarshal(b, &pkg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.Vcs, p.Repo = labelToVcs[pkg.Vcs], pkg.Repo
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user