From f24c4fe2123079be00b65a9c2a4844d9a2cf9615 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Mon, 26 Aug 2024 17:05:23 -0700 Subject: [PATCH] all: Fix duplicate [start:..] markers --- docs/ex/get-started/02-http-server/main.go | 18 ++++++++--------- docs/ex/get-started/03-echo-handler/main.go | 8 ++++---- docs/ex/get-started/04-logger/main.go | 8 ++++---- .../ex/get-started/06-another-handler/main.go | 20 +++++++++---------- docs/ex/value-groups/consume/annotate.go | 2 +- docs/src/get-started/another-handler.md | 7 +++++-- docs/src/get-started/echo-handler.md | 3 ++- docs/src/get-started/http-server.md | 6 ++++-- docs/src/get-started/logger.md | 3 ++- 9 files changed, 41 insertions(+), 34 deletions(-) diff --git a/docs/ex/get-started/02-http-server/main.go b/docs/ex/get-started/02-http-server/main.go index 1d98974c3..708fbe845 100644 --- a/docs/ex/get-started/02-http-server/main.go +++ b/docs/ex/get-started/02-http-server/main.go @@ -29,28 +29,28 @@ import ( "go.uber.org/fx" ) -// --8<-- [start:provide-server] +// --8<-- [start:provide-server-1] func main() { // --8<-- [start:app] fx.New( fx.Provide(NewHTTPServer), - // --8<-- [end:provide-server] + // --8<-- [end:provide-server-1] fx.Invoke(func(*http.Server) {}), - // --8<-- [start:provide-server] + // --8<-- [start:provide-server-2] ).Run() // --8<-- [end:app] } -// --8<-- [end:provide-server] +// --8<-- [end:provide-server-2] -// --8<-- [start:partial] +// --8<-- [start:partial-1] // NewHTTPServer builds an HTTP server that will begin serving requests // when the Fx application starts. // --8<-- [start:full] func NewHTTPServer(lc fx.Lifecycle) *http.Server { srv := &http.Server{Addr: ":8080"} - // --8<-- [end:partial] + // --8<-- [end:partial-1] lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { ln, err := net.Listen("tcp", srv.Addr) @@ -65,9 +65,9 @@ func NewHTTPServer(lc fx.Lifecycle) *http.Server { return srv.Shutdown(ctx) }, }) - // --8<-- [start:partial] + // --8<-- [start:partial-2] return srv } -// --8<-- [end:partial] -// --8<-- [start:full] +// --8<-- [end:partial-2] +// --8<-- [end:full] diff --git a/docs/ex/get-started/03-echo-handler/main.go b/docs/ex/get-started/03-echo-handler/main.go index 758aca226..af3c1863d 100644 --- a/docs/ex/get-started/03-echo-handler/main.go +++ b/docs/ex/get-started/03-echo-handler/main.go @@ -34,17 +34,17 @@ import ( func main() { fx.New( // --8<-- [start:provides] - // --8<-- [start:provide-handler] + // --8<-- [start:provide-handler-1] fx.Provide( NewHTTPServer, - // --8<-- [end:provide-handler] + // --8<-- [end:provide-handler-1] NewServeMux, - // --8<-- [start:provide-handler] + // --8<-- [start:provide-handler-2] NewEchoHandler, ), // --8<-- [end:provides] fx.Invoke(func(*http.Server) {}), - // --8<-- [end:provide-handler] + // --8<-- [end:provide-handler-2] ).Run() } diff --git a/docs/ex/get-started/04-logger/main.go b/docs/ex/get-started/04-logger/main.go index 81f1e72f2..f6db423cc 100644 --- a/docs/ex/get-started/04-logger/main.go +++ b/docs/ex/get-started/04-logger/main.go @@ -60,20 +60,20 @@ func NewServeMux(echo *EchoHandler) *http.ServeMux { // EchoHandler is an http.Handler that copies its request body // back to the response. -// --8<-- [start:echo-init] +// --8<-- [start:echo-init-1] type EchoHandler struct { log *zap.Logger } -// --8<-- [end:echo-init] +// --8<-- [end:echo-init-1] // NewEchoHandler builds a new EchoHandler. -// --8<-- [start:echo-init] +// --8<-- [start:echo-init-2] func NewEchoHandler(log *zap.Logger) *EchoHandler { return &EchoHandler{log: log} } -// --8<-- [end:echo-init] +// --8<-- [end:echo-init-2] // ServeHTTP handles an HTTP request to the /echo endpoint. // --8<-- [start:echo-serve] diff --git a/docs/ex/get-started/06-another-handler/main.go b/docs/ex/get-started/06-another-handler/main.go index 731062cdb..f30593732 100644 --- a/docs/ex/get-started/06-another-handler/main.go +++ b/docs/ex/get-started/06-another-handler/main.go @@ -45,23 +45,23 @@ func main() { fx.ParamTags(`name:"echo"`, `name:"hello"`), ), // --8<-- [end:mux-provide] - // --8<-- [start:hello-provide-partial] + // --8<-- [start:hello-provide-partial-1] // --8<-- [start:route-provides] fx.Annotate( NewEchoHandler, fx.As(new(Route)), - // --8<-- [end:hello-provide-partial] + // --8<-- [end:hello-provide-partial-1] fx.ResultTags(`name:"echo"`), - // --8<-- [start:hello-provide-partial] + // --8<-- [start:hello-provide-partial-2] ), fx.Annotate( NewHelloHandler, fx.As(new(Route)), - // --8<-- [end:hello-provide-partial] + // --8<-- [end:hello-provide-partial-2] fx.ResultTags(`name:"hello"`), - // --8<-- [start:hello-provide-partial] + // --8<-- [start:hello-provide-partial-3] ), - // --8<-- [end:hello-provide-partial] + // --8<-- [end:hello-provide-partial-3] // --8<-- [end:route-provides] zap.NewExample, ), @@ -108,15 +108,15 @@ func NewHelloHandler(log *zap.Logger) *HelloHandler { // Pattern reports the pattern under which // this handler should be registered. -// --8<-- [start:hello-methods] +// --8<-- [start:hello-methods-1] func (*HelloHandler) Pattern() string { return "/hello" } -// --8<-- [end:hello-methods] +// --8<-- [end:hello-methods-1] // ServeHTTP handles an HTTP request to the /hello endpoint. -// --8<-- [start:hello-methods] +// --8<-- [start:hello-methods-2] func (h *HelloHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) if err != nil { @@ -132,7 +132,7 @@ func (h *HelloHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } -// --8<-- [end:hello-methods] +// --8<-- [end:hello-methods-2] // EchoHandler is an http.Handler that copies its request body // back to the response. diff --git a/docs/ex/value-groups/consume/annotate.go b/docs/ex/value-groups/consume/annotate.go index 6a02c0d25..9f1aad054 100644 --- a/docs/ex/value-groups/consume/annotate.go +++ b/docs/ex/value-groups/consume/annotate.go @@ -78,6 +78,6 @@ var EmitterFromModule = fx.Options( // EmitterFrom builds an Emitter from the list of watchers. // --8<-- [start:new-variadic] func EmitterFrom(watchers ...Watcher) (*Emitter, error) { - // --8<-- [start:new-variadic] + // --8<-- [end:new-variadic] return &Emitter{ws: watchers}, nil } diff --git a/docs/src/get-started/another-handler.md b/docs/src/get-started/another-handler.md index 7a543dc14..dab0fe4fd 100644 --- a/docs/src/get-started/another-handler.md +++ b/docs/src/get-started/another-handler.md @@ -12,7 +12,8 @@ Let's add another. 2. Implement the `Route` interface for this handler. ```go - --8<-- "get-started/06-another-handler/main.go:hello-methods" + --8<-- "get-started/06-another-handler/main.go:hello-methods-1" + --8<-- "get-started/06-another-handler/main.go:hello-methods-2" ``` The handler reads its request body, @@ -21,7 +22,9 @@ Let's add another. 3. Provide this to the application as a `Route` next to `NewEchoHandler`. ```go - --8<-- "get-started/06-another-handler/main.go:hello-provide-partial" + --8<-- "get-started/06-another-handler/main.go:hello-provide-partial-1" + --8<-- "get-started/06-another-handler/main.go:hello-provide-partial-2" + --8<-- "get-started/06-another-handler/main.go:hello-provide-partial-3" ``` 4. Run the application--the service will fail to start. diff --git a/docs/src/get-started/echo-handler.md b/docs/src/get-started/echo-handler.md index b6f3606d8..067fefe7a 100644 --- a/docs/src/get-started/echo-handler.md +++ b/docs/src/get-started/echo-handler.md @@ -15,7 +15,8 @@ Let's fix that. Provide this to the application. ```go - --8<-- "get-started/03-echo-handler/main.go:provide-handler" + --8<-- "get-started/03-echo-handler/main.go:provide-handler-1" + --8<-- "get-started/03-echo-handler/main.go:provide-handler-2" ``` 2. Next, write a function that builds an `*http.ServeMux`. diff --git a/docs/src/get-started/http-server.md b/docs/src/get-started/http-server.md index 128f572b4..e8e3e9bde 100644 --- a/docs/src/get-started/http-server.md +++ b/docs/src/get-started/http-server.md @@ -7,7 +7,8 @@ Let's add an HTTP server to it. 1. Write a function to build your HTTP server. ```go - --8<-- "get-started/02-http-server/main.go:partial" + --8<-- "get-started/02-http-server/main.go:partial-1" + --8<-- "get-started/02-http-server/main.go:partial-2" ``` This isn't enough, though--we need to tell Fx how to start the HTTP server. @@ -23,7 +24,8 @@ Let's add an HTTP server to it. 3. Provide this to your Fx application above with `fx.Provide`. ```go - --8<-- "get-started/02-http-server/main.go:provide-server" + --8<-- "get-started/02-http-server/main.go:provide-server-1" + --8<-- "get-started/02-http-server/main.go:provide-server-2" ``` 4. Run the application. diff --git a/docs/src/get-started/logger.md b/docs/src/get-started/logger.md index fdfffd574..527d2c287 100644 --- a/docs/src/get-started/logger.md +++ b/docs/src/get-started/logger.md @@ -22,7 +22,8 @@ but you should be able to use any logging system. and in `NewEchoHandler` add a new logger argument to set this field. ```go - --8<-- "get-started/04-logger/main.go:echo-init" + --8<-- "get-started/04-logger/main.go:echo-init-1" + --8<-- "get-started/04-logger/main.go:echo-init-2" ``` 3. In the `EchoHandler.ServeHTTP` method,