Skip to content

Commit be553c3

Browse files
committed
Fix example
1 parent 4d5225d commit be553c3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modal-go/examples/sandbox-image-mount/main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ func main() {
103103
if err != nil {
104104
log.Fatalf("Failed to create second Sandbox: %v", err)
105105
}
106+
sb2FromID, err := mc.Sandboxes.FromID(ctx, sb2.SandboxID)
107+
if err != nil {
108+
log.Fatalf("Failed to create Sandbox: %v", err)
109+
}
106110
defer func() {
107-
if _, err := sb2.Terminate(context.Background(), nil); err != nil {
111+
if _, err := sb2FromID.Terminate(context.Background(), nil); err != nil {
108112
log.Fatalf("Failed to terminate Sandbox %s: %v", sb2.SandboxID, err)
109113
}
110114
}()
@@ -134,6 +138,10 @@ func main() {
134138
}
135139
fmt.Printf("Contents of /repo directory in new Sandbox sb2:\n%s", output)
136140

141+
if _, err := sb2.Terminate(ctx, nil); err != nil {
142+
log.Fatalf("Failed to terminate sb2: %v", err)
143+
}
144+
137145
if err := mc.Images.Delete(ctx, repoSnapshot.ImageID, nil); err != nil {
138146
log.Fatalf("Failed to delete snapshot image: %v", err)
139147
}

0 commit comments

Comments
 (0)