Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit fc4f862

Browse files
committed
Remove JSON marshaling for lock and manifest
1 parent 793be89 commit fc4f862

File tree

2 files changed

+19
-45
lines changed

2 files changed

+19
-45
lines changed

lock.go

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package dep
77
import (
88
"bytes"
99
"encoding/hex"
10-
"encoding/json"
1110
"fmt"
1211
"io"
1312
"sort"
@@ -25,17 +24,17 @@ type Lock struct {
2524
}
2625

2726
type rawLock struct {
28-
Memo string `json:"memo"`
29-
P []lockedDep `json:"projects"`
27+
Memo string
28+
P []lockedDep
3029
}
3130

3231
type lockedDep struct {
33-
Name string `json:"name"`
34-
Version string `json:"version,omitempty"`
35-
Branch string `json:"branch,omitempty"`
36-
Revision string `json:"revision"`
37-
Source string `json:"source,omitempty"`
38-
Packages []string `json:"packages"`
32+
Name string
33+
Version string
34+
Branch string
35+
Revision string
36+
Source string
37+
Packages []string
3938
}
4039

4140
func readLock(r io.Reader) (*Lock, error) {
@@ -115,18 +114,6 @@ func (l *Lock) toRaw() rawLock {
115114
return raw
116115
}
117116

118-
func (l *Lock) MarshalJSON() ([]byte, error) {
119-
raw := l.toRaw()
120-
121-
var buf bytes.Buffer
122-
enc := json.NewEncoder(&buf)
123-
enc.SetIndent("", " ")
124-
enc.SetEscapeHTML(false)
125-
err := enc.Encode(raw)
126-
127-
return buf.Bytes(), err
128-
}
129-
130117
func (l *Lock) MarshalTOML() (string, error) {
131118
raw := l.toRaw()
132119

manifest.go

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package dep
66

77
import (
8-
"bytes"
98
"encoding/json"
109
"fmt"
1110
"io"
@@ -25,17 +24,10 @@ type Manifest struct {
2524
}
2625

2726
type rawManifest struct {
28-
Dependencies map[string]possibleProps `json:"dependencies,omitempty"`
29-
Overrides map[string]possibleProps `json:"overrides,omitempty"`
30-
Ignores []string `json:"ignores,omitempty"`
31-
Required []string `json:"required,omitempty"`
32-
}
33-
34-
type possibleProps struct {
35-
Branch string `json:"branch,omitempty"`
36-
Revision string `json:"revision,omitempty"`
37-
Version string `json:"version,omitempty"`
38-
Source string `json:"source,omitempty"`
27+
Dependencies map[string]possibleProps
28+
Overrides map[string]possibleProps
29+
Ignores []string
30+
Required []string
3931
}
4032

4133
func newRawManifest() rawManifest {
@@ -47,6 +39,13 @@ func newRawManifest() rawManifest {
4739
}
4840
}
4941

42+
type possibleProps struct {
43+
Branch string
44+
Revision string
45+
Version string
46+
Source string
47+
}
48+
5049
func readManifest(r io.Reader) (*Manifest, error) {
5150
rm := rawManifest{}
5251
err := json.NewDecoder(r).Decode(&rm)
@@ -127,18 +126,6 @@ func (m *Manifest) toRaw() rawManifest {
127126
return raw
128127
}
129128

130-
func (m *Manifest) MarshalJSON() ([]byte, error) {
131-
raw := m.toRaw()
132-
133-
var buf bytes.Buffer
134-
enc := json.NewEncoder(&buf)
135-
enc.SetIndent("", " ")
136-
enc.SetEscapeHTML(false)
137-
err := enc.Encode(raw)
138-
139-
return buf.Bytes(), err
140-
}
141-
142129
func (m *Manifest) MarshalTOML() (string, error) {
143130
raw := m.toRaw()
144131

0 commit comments

Comments
 (0)