Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into debug-repl
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed May 29, 2023
2 parents 2512543 + 787a667 commit f67874e
Show file tree
Hide file tree
Showing 33 changed files with 1,062 additions and 328 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ flatbuffers: go.mod $(format.src.go)
$(GO) build ./format/...

test: flatbuffers testdata
$(GO) test -v ./...
$(GO) test ./...

testdata: $(testdata.go.wasm)

Expand Down
18 changes: 13 additions & 5 deletions format/timecraft.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ func SHA256(b []byte) Hash {
}
}

func ParseHash(s string) (h Hash, err error) {
var ok bool
h.Algorithm, h.Digest, ok = strings.Cut(s, ":")
func ParseHash(s string) Hash {
algorithm, digest, ok := strings.Cut(s, ":")
if !ok {
err = fmt.Errorf("malformed hash: %s", s)
algorithm, digest = "sha256", s
}
return h, err
return Hash{Algorithm: algorithm, Digest: digest}
}

func (h Hash) Short() string {
s := h.Digest
if len(s) > 12 {
s = s[:12]
}
return s
}

func (h Hash) String() string {
Expand Down Expand Up @@ -123,6 +130,7 @@ func (m *Module) UnmarshalResource(b []byte) error {
}

type Runtime struct {
Runtime string `json:"runtime" yaml:"runtime"`
Version string `json:"version" yaml:"version"`
}

Expand Down
Loading

0 comments on commit f67874e

Please sign in to comment.