diff --git a/docs/get-started/foundations/infrastructure/resources.mdx b/docs/get-started/foundations/infrastructure/resources.mdx index 3fd07fc55..c666428b8 100644 --- a/docs/get-started/foundations/infrastructure/resources.mdx +++ b/docs/get-started/foundations/infrastructure/resources.mdx @@ -91,25 +91,17 @@ import ( ) func main() { - api, err := nitric.NewApi("public") - if err != nil { - fmt.Println(err) - return - } + api := nitric.NewApi("public") // ✅ This declaration will work - bucket, err := nitric.NewBucket("files").Allow(nitric.BucketRead) + bucket := nitric.NewBucket("files").Allow(nitric.BucketRead) api.Get("/files/:name", func(ctx *apis.Ctx) { // ❌ This declaration won't work, since it's in a callback that's only called at runtime. - badBucket, err := nitric.NewBucket("wont-work").Allow(nitric.BucketRead) + badBucket := nitric.NewBucket("wont-work").Allow(nitric.BucketRead) }) - if err := nitric.Run(); err != nil { - fmt.Println(err) - } - - fmt.Println("Service has started") + nitric.Run() } ``` @@ -202,14 +194,14 @@ import ( ) func main() { - api, err := nitric.NewApi("public") + api := nitric.NewApi("public") if err != nil { fmt.Println(err) return } - bucket, err := nitric.NewBucket("files").Allow(nitric.BucketRead) + bucket := nitric.NewBucket("files").Allow(nitric.BucketRead) // ❌ This access will not work fileContents, _ := bucket.Read(context.TODO(), "example.txt") @@ -219,9 +211,7 @@ func main() { fileContents, _ := bucket.Read(context.TODO(), "example.txt") }) - if err := nitric.Run(); err != nil { - fmt.Println(err) - } + nitric.Run() } ``` @@ -389,10 +379,7 @@ var PublicApi nitric.Api var UpdateTopic nitric.SubscribableTopic func init() { - publicApi, err := nitric.NewApi("public") - if err != nil { - panic(err) - } + publicApi := nitric.NewApi("public") PublicApi = publicApi @@ -424,9 +411,7 @@ func main() { }) }) - if err := nitric.Run(); err != nil { - fmt.Println(err) - } + nitric.Run() } ``` @@ -445,11 +430,7 @@ func main() { println("got the message") }) - if err := nitric.Run(); err != nil { - fmt.Println(err) - } - - fmt.Println("Updates service has started") + nitric.Run() } ``` @@ -644,9 +625,7 @@ func main() { // do something with the file }) - if err := nitric.Run(); err != nil { - fmt.Println(err) - } + nitric.Run() } ``` @@ -666,9 +645,7 @@ func main() { // do something with the file }) - if err := nitric.Run(); err != nil { - fmt.Println(err) - } + nitric.Run() } ``` diff --git a/docs/get-started/quickstart.mdx b/docs/get-started/quickstart.mdx index 27dc557fb..ac9c57927 100644 --- a/docs/get-started/quickstart.mdx +++ b/docs/get-started/quickstart.mdx @@ -337,11 +337,7 @@ import ( ) func main() { - api, err := nitric.NewApi("main") - if err != nil { - fmt.Println(err) - return - } + api := nitric.NewApi("main") api.Get("/hello/:name", func(ctx *apis.Ctx) { name := ctx.Request.PathParams()["name"] @@ -353,9 +349,7 @@ func main() { ctx.Response.Body = []byte(fmt.Sprintf("Goodbye %s", name)) }) - if err := nitric.Run(); err != nil { - fmt.Println(err) - } + nitric.Run() } ``` diff --git a/docs/index.mdx b/docs/index.mdx index db2f1752c..d82660822 100644 --- a/docs/index.mdx +++ b/docs/index.mdx @@ -153,11 +153,9 @@ import ( ) func main() { - profiles, _ := nitric.NewBucket("profiles").Allow(nitric.BucketRead, nitric.BucketWrite, nitric.BucketDelete) + profiles := nitric.NewBucket("profiles").Allow(nitric.BucketRead, nitric.BucketWrite, nitric.BucketDelete) - if err := nitric.Run(); err != nil { - fmt.Println(err) - } + nitric.Run() } ``` diff --git a/docs/reference/go/api/api-delete.mdx b/docs/reference/go/api/api-delete.mdx index be362c5bd..000721c31 100644 --- a/docs/reference/go/api/api-delete.mdx +++ b/docs/reference/go/api/api-delete.mdx @@ -20,10 +20,7 @@ import ( ) func main() { - api, err := nitric.NewApi("public") - if err != nil { - return - } + api := nitric.NewApi("public") api.Delete("/hello", func(ctx *apis.Ctx) { ctx.Response.Body = []byte("Hello World") diff --git a/docs/reference/go/storage/bucket-downloadurl.mdx b/docs/reference/go/storage/bucket-downloadurl.mdx index 6a24be228..365576e4f 100644 --- a/docs/reference/go/storage/bucket-downloadurl.mdx +++ b/docs/reference/go/storage/bucket-downloadurl.mdx @@ -54,10 +54,7 @@ import ( ) func main() { - bucket, err := nitric.NewBucket("bucket-name").Allow(nitric.BucketRead) - if err != nil { - return - } + bucket := nitric.NewBucket("bucket-name").Allow(nitric.BucketRead) downloadUrl, err := bucket.File("cat.png").DownloadUrl(context.TODO(), "cat.png", storage.WithPresignUrlExpiry(time.Minute*5)) if err != nil { @@ -80,15 +77,9 @@ import ( ) func main() { - api, err := nitric.NewApi("main") - if err != nil { - return - } + api := nitric.NewApi("main") - bucket, err := nitric.NewBucket("images").Allow(nitric.BucketRead) - if err != nil { - return - } + bucket := nitric.NewBucket("images").Allow(nitric.BucketRead) api.Get("/images/:id", func(ctx *apis.Ctx) { id := ctx.Request.PathParams()["id"]