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

Commit

Permalink
Remove JSON marshaling for lock and manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
carolynvs committed Mar 29, 2017
1 parent 793be89 commit fc4f862
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 45 deletions.
29 changes: 8 additions & 21 deletions lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package dep
import (
"bytes"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"sort"
Expand All @@ -25,17 +24,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) {
Expand Down Expand Up @@ -115,18 +114,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()

Expand Down
35 changes: 11 additions & 24 deletions manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package dep

import (
"bytes"
"encoding/json"
"fmt"
"io"
Expand All @@ -25,17 +24,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 {
Expand All @@ -47,6 +39,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)
Expand Down Expand Up @@ -127,18 +126,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()

Expand Down

0 comments on commit fc4f862

Please sign in to comment.