зеркало из https://github.com/golang/dep.git
Remove JSON marshaling for lock and manifest
This commit is contained in:
Родитель
d82a114f1b
Коммит
56476c3d49
29
lock.go
29
lock.go
|
@ -5,7 +5,6 @@
|
|||
package dep
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
@ -24,17 +23,17 @@ type Lock struct {
|
|||
}
|
||||
|
||||
type rawLock struct {
|
||||
Memo string `json:"memo"`
|
||||
P []lockedDep `json:"projects"`
|
||||
Memo string
|
||||
P []lockedDep
|
||||
}
|
||||
|
||||
type lockedDep struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Branch string `json:"branch,omitempty"`
|
||||
Revision string `json:"revision"`
|
||||
Source string `json:"source,omitempty"`
|
||||
Packages []string `json:"packages"`
|
||||
Name string
|
||||
Version string
|
||||
Branch string
|
||||
Revision string
|
||||
Source string
|
||||
Packages []string
|
||||
}
|
||||
|
||||
func readLock(r io.Reader) (*Lock, error) {
|
||||
|
@ -114,18 +113,6 @@ func (l *Lock) toRaw() rawLock {
|
|||
return raw
|
||||
}
|
||||
|
||||
func (l *Lock) MarshalJSON() ([]byte, error) {
|
||||
raw := l.toRaw()
|
||||
|
||||
var buf bytes.Buffer
|
||||
enc := json.NewEncoder(&buf)
|
||||
enc.SetIndent("", " ")
|
||||
enc.SetEscapeHTML(false)
|
||||
err := enc.Encode(raw)
|
||||
|
||||
return buf.Bytes(), err
|
||||
}
|
||||
|
||||
func (l *Lock) MarshalTOML() (string, error) {
|
||||
raw := l.toRaw()
|
||||
|
||||
|
|
35
manifest.go
35
manifest.go
|
@ -5,7 +5,6 @@
|
|||
package dep
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
||||
|
@ -24,17 +23,10 @@ type Manifest struct {
|
|||
}
|
||||
|
||||
type rawManifest struct {
|
||||
Dependencies map[string]possibleProps `json:"dependencies,omitempty"`
|
||||
Overrides map[string]possibleProps `json:"overrides,omitempty"`
|
||||
Ignores []string `json:"ignores,omitempty"`
|
||||
Required []string `json:"required,omitempty"`
|
||||
}
|
||||
|
||||
type possibleProps struct {
|
||||
Branch string `json:"branch,omitempty"`
|
||||
Revision string `json:"revision,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Source string `json:"source,omitempty"`
|
||||
Dependencies map[string]possibleProps
|
||||
Overrides map[string]possibleProps
|
||||
Ignores []string
|
||||
Required []string
|
||||
}
|
||||
|
||||
func newRawManifest() rawManifest {
|
||||
|
@ -46,6 +38,13 @@ func newRawManifest() rawManifest {
|
|||
}
|
||||
}
|
||||
|
||||
type possibleProps struct {
|
||||
Branch string
|
||||
Revision string
|
||||
Version string
|
||||
Source string
|
||||
}
|
||||
|
||||
func readManifest(r io.Reader) (*Manifest, error) {
|
||||
rm := rawManifest{}
|
||||
err := json.NewDecoder(r).Decode(&rm)
|
||||
|
@ -126,18 +125,6 @@ func (m *Manifest) toRaw() rawManifest {
|
|||
return raw
|
||||
}
|
||||
|
||||
func (m *Manifest) MarshalJSON() ([]byte, error) {
|
||||
raw := m.toRaw()
|
||||
|
||||
var buf bytes.Buffer
|
||||
enc := json.NewEncoder(&buf)
|
||||
enc.SetIndent("", " ")
|
||||
enc.SetEscapeHTML(false)
|
||||
err := enc.Encode(raw)
|
||||
|
||||
return buf.Bytes(), err
|
||||
}
|
||||
|
||||
func (m *Manifest) MarshalTOML() (string, error) {
|
||||
raw := m.toRaw()
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче