Skip to content

Commit

Permalink
docs: Fix panics in cookbook code (dagger#7521)
Browse files Browse the repository at this point in the history
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
  • Loading branch information
vikram-dagger committed May 31, 2024
1 parent 0a48b7d commit 820f430
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (m *MyModule) Build(
// Source code location
// can be local directory or remote Git repository
src *Directory,
) string {
) (string, error) {
// platforms to build for and push in a multi-platform image
var platforms = []Platform{
"linux/amd64", // a.k.a. x86_64
Expand Down Expand Up @@ -57,9 +57,9 @@ func (m *MyModule) Build(
})

if err != nil {
panic(err)
return "", err
}

// return build directory
return imageDigest
return imageDigest, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (m *MyModule) Build(
// source code location
// can be local directory or remote Git repository
src *Directory,
) string {
) (string, error) {
// build app
builder := dag.Container().
From("golang:latest").
Expand All @@ -30,8 +30,8 @@ func (m *MyModule) Build(
// publish to ttl.sh registry
addr, err := prodImage.Publish(ctx, "ttl.sh/myapp:latest")
if err != nil {
panic(err)
return "", err
}

return addr
return addr, nil
}

0 comments on commit 820f430

Please sign in to comment.