Skip to content

Commit

Permalink
Changed to pointer receiver when both were mixed
Browse files Browse the repository at this point in the history
- Changed to pointer receiver when both were mixed.
- https://go.dev/doc/faq#methods_on_values_or_pointers

Signed-off-by: naveensrinivasan <[email protected]>
  • Loading branch information
naveensrinivasan authored and jkjell committed Nov 15, 2023
1 parent 08d1c37 commit c487391
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions attestation/material/material.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ type Attestor struct {
materials map[string]cryptoutil.DigestSet
}

func (a Attestor) Name() string {
func (a *Attestor) Name() string {
return Name
}

func (a Attestor) Type() string {
func (a *Attestor) Type() string {
return Type
}

func (rc *Attestor) RunType() attestation.RunType {
func (a *Attestor) RunType() attestation.RunType {
return RunType
}

Expand Down
6 changes: 3 additions & 3 deletions attestation/product/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ func fromDigestMap(digestMap map[string]cryptoutil.DigestSet) map[string]attesta
return products
}

func (a Attestor) Name() string {
func (a *Attestor) Name() string {
return Name
}

func (a Attestor) Type() string {
func (a *Attestor) Type() string {
return Type
}

func (rc *Attestor) RunType() attestation.RunType {
func (a *Attestor) RunType() attestation.RunType {
return RunType
}

Expand Down
12 changes: 6 additions & 6 deletions cryptoutil/digestset.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ func (first DigestSet) Equal(second DigestSet) bool {
return hasMatchingDigest
}

func (ds DigestSet) ToNameMap() (map[string]string, error) {
func (first DigestSet) ToNameMap() (map[string]string, error) {
nameMap := make(map[string]string)
for hash, digest := range ds {
for hash, digest := range first {
name, ok := hashNames[hash]
if !ok {
return nameMap, ErrUnsupportedHash(hash.String())
Expand Down Expand Up @@ -190,16 +190,16 @@ func CalculateDigestSetFromFile(path string, hashes []crypto.Hash) (DigestSet, e
return CalculateDigestSet(file, hashes)
}

func (ds DigestSet) MarshalJSON() ([]byte, error) {
nameMap, err := ds.ToNameMap()
func (first DigestSet) MarshalJSON() ([]byte, error) {
nameMap, err := first.ToNameMap()
if err != nil {
return nil, err
}

return json.Marshal(nameMap)
}

func (ds *DigestSet) UnmarshalJSON(data []byte) error {
func (first *DigestSet) UnmarshalJSON(data []byte) error {
nameMap := make(map[string]string)
err := json.Unmarshal(data, &nameMap)
if err != nil {
Expand All @@ -211,7 +211,7 @@ func (ds *DigestSet) UnmarshalJSON(data []byte) error {
return err
}

*ds = newDs
*first = newDs
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions registry/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type ConfigOption[T any, TOption Option] struct {
setter func(T, TOption) (T, error)
}

func (co ConfigOption[T, TOption]) Name() string {
func (co *ConfigOption[T, TOption]) Name() string {
if len(co.prefix) == 0 {
return co.name
}
Expand All @@ -49,15 +49,15 @@ func (co *ConfigOption[T, TOption]) SetPrefix(prefix string) {
co.prefix = prefix
}

func (co ConfigOption[T, TOption]) DefaultVal() TOption {
func (co *ConfigOption[T, TOption]) DefaultVal() TOption {
return co.defaultVal
}

func (co ConfigOption[T, TOption]) Description() string {
func (co *ConfigOption[T, TOption]) Description() string {
return co.description
}

func (co ConfigOption[T, TOption]) Setter() func(T, TOption) (T, error) {
func (co *ConfigOption[T, TOption]) Setter() func(T, TOption) (T, error) {
return co.setter
}

Expand Down

0 comments on commit c487391

Please sign in to comment.