From e755e4a82368c3310050a1448099b36f59d04afb Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Thu, 13 Nov 2025 18:17:45 +0000 Subject: [PATCH] updates for syntax highlighting --- README.md | 10 ++++---- internal/website/_config.yml | 9 +++++++ internal/website/docs/broker.md | 4 +-- internal/website/docs/getting-started.md | 32 ++++++++++++------------ internal/website/docs/server.md | 4 +-- internal/website/docs/store.md | 4 +-- internal/website/docs/transport.md | 4 +-- 7 files changed, 38 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 7705250a..1b6d65fe 100644 --- a/README.md +++ b/README.md @@ -49,13 +49,13 @@ in the plugins repo. State and persistence becomes a core requirement beyond pro To make use of Go Micro -```golang +```bash go get go-micro.dev/v5@latest ``` Create a service and register a handler -```golang +```go package main import ( @@ -91,7 +91,7 @@ func main() { Set a fixed address -```golang +```go service := micro.NewService( micro.Name("helloworld"), micro.Address(":8080"), @@ -100,7 +100,7 @@ service := micro.NewService( Call it via curl -``` +```bash curl -XPOST \ -H 'Content-Type: application/json' \ -H 'Micro-Endpoint: Say.Hello' \ @@ -116,7 +116,7 @@ There's a new `genai` package for generative AI capabilities. Install the code generator and see usage in the docs: -``` +```bash go install go-micro.dev/v5/cmd/protoc-gen-micro@latest ``` diff --git a/internal/website/_config.yml b/internal/website/_config.yml index 53914c3a..961e5b26 100644 --- a/internal/website/_config.yml +++ b/internal/website/_config.yml @@ -4,3 +4,12 @@ baseurl: "" # the subpath of your site, e.g. /blog url: "" # the base hostname & protocol for your site, e.g. http://example.com theme: jekyll-theme-primer + +# Enable syntax highlighting +highlighter: rouge +markdown: kramdown +kramdown: + input: GFM + syntax_highlighter: rouge + syntax_highlighter_opts: + line_numbers: false diff --git a/internal/website/docs/broker.md b/internal/website/docs/broker.md index 91248e29..5a986459 100644 --- a/internal/website/docs/broker.md +++ b/internal/website/docs/broker.md @@ -96,8 +96,8 @@ func main() { Using the built-in configuration flags/env vars (no code changes): -``` -MICRO_BROKER=nats MICRO_BROKER_ADDRESS=nats://127.0.0.1:4222 micro server +```bash +MICRO_BROKER=nats MICRO_BROKER_ADDRESS=nats://127.0.0.1:4222 go run main.go ``` Common variables: diff --git a/internal/website/docs/getting-started.md b/internal/website/docs/getting-started.md index 0b1633e1..a3fb37e5 100644 --- a/internal/website/docs/getting-started.md +++ b/internal/website/docs/getting-started.md @@ -6,7 +6,7 @@ layout: default To make use of Go Micro -```golang +```bash go get go-micro.dev/v5@latest ``` @@ -14,7 +14,7 @@ go get go-micro.dev/v5@latest This is a basic example of how you'd create a service and register a handler in pure Go. -``` +```bash mkdir helloworld cd helloworld go mod init @@ -23,7 +23,7 @@ go get go-micro.dev/v5@latest Write the following into `main.go` -```golang +```go package main import ( @@ -62,19 +62,19 @@ func main() { Now run the service -``` +```bash go run main.go ``` Take a note of the address with the log line -``` +```text Transport [http] Listening on [::]:35823 ``` Now you can call the service -``` +```bash curl -XPOST \ -H 'Content-Type: application/json' \ -H 'Micro-Endpoint: Say.Hello' \ @@ -86,7 +86,7 @@ curl -XPOST \ To set a fixed address by specifying it as an option to service, note the change from `New` to `NewService` -```golang +```go service := micro.NewService( micro.Name("helloworld"), micro.Address(":8080"), @@ -95,7 +95,7 @@ service := micro.NewService( Alternatively use `MICRO_SERVER_ADDRESS=:8080` as an env var -``` +```bash curl -XPOST \ -H 'Content-Type: application/json' \ -H 'Micro-Endpoint: Say.Hello' \ @@ -109,18 +109,18 @@ If you want to define services with protobuf you can use protoc-gen-micro (go-mi Install the generator: -``` +```bash go install go-micro.dev/v5/cmd/protoc-gen-micro@latest ``` -``` +```bash cd helloworld mkdir proto ``` Edit a file `proto/helloworld.proto` -``` +```proto syntax = "proto3"; package greeter; @@ -141,13 +141,13 @@ message Response { You can now generate a client/server like so (ensure `$GOBIN` is on your `$PATH` so `protoc` can find `protoc-gen-micro`): -``` +```bash protoc --proto_path=. --micro_out=. --go_out=. helloworld.proto ``` In your `main.go` update the code to reference the generated code -``` +```go package main import ( @@ -171,7 +171,7 @@ func main() { service.Init() // register handler - proto.RegisterSayHandler(service.Server(), &Say{}) + pb.RegisterSayHandler(service.Server(), &Say{}) // run the service service.Run() @@ -180,7 +180,7 @@ func main() { Now I can run this again -``` +```bash go run main.go ``` @@ -188,7 +188,7 @@ go run main.go The generated code provides us a client -``` +```go package main import ( diff --git a/internal/website/docs/server.md b/internal/website/docs/server.md index 6f6b3d75..7837f577 100644 --- a/internal/website/docs/server.md +++ b/internal/website/docs/server.md @@ -10,7 +10,7 @@ The Micro server is an optional API and dashboard that provides a fixed entrypoi Install the CLI which includes the server command: -``` +```bash go install go-micro.dev/v5/cmd/micro@latest ``` @@ -18,7 +18,7 @@ go install go-micro.dev/v5/cmd/micro@latest Start the server: -``` +```bash micro server ``` diff --git a/internal/website/docs/store.md b/internal/website/docs/store.md index 4a854c91..d33ca712 100644 --- a/internal/website/docs/store.md +++ b/internal/website/docs/store.md @@ -87,10 +87,10 @@ func main() { ## Configure via environment -``` +```bash MICRO_STORE=postgres MICRO_STORE_ADDRESS=postgres://user:pass@127.0.0.1:5432/db \ MICRO_STORE_DATABASE=micro MICRO_STORE_TABLE=micro \ -micro server +go run main.go ``` Common variables: diff --git a/internal/website/docs/transport.md b/internal/website/docs/transport.md index 69568063..d4c515ef 100644 --- a/internal/website/docs/transport.md +++ b/internal/website/docs/transport.md @@ -60,8 +60,8 @@ func main() { ## Configure via environment -``` -MICRO_TRANSPORT=nats MICRO_TRANSPORT_ADDRESS=nats://127.0.0.1:4222 micro server +```bash +MICRO_TRANSPORT=nats MICRO_TRANSPORT_ADDRESS=nats://127.0.0.1:4222 go run main.go ``` Common variables: