From 6395b7eaf6fcb8827255550e7a636bf45211a6b8 Mon Sep 17 00:00:00 2001 From: pegasas Date: Sun, 10 Sep 2023 01:14:55 +0800 Subject: [PATCH] Golang Getting started - based on roll dice service and Automatic Instrumentation --- .../instrumentation/go/getting-started.md | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/content/en/docs/instrumentation/go/getting-started.md b/content/en/docs/instrumentation/go/getting-started.md index ad858edad37b..94fb992078de 100644 --- a/content/en/docs/instrumentation/go/getting-started.md +++ b/content/en/docs/instrumentation/go/getting-started.md @@ -31,19 +31,22 @@ directory[^1]. ```go package main -// Fibonacci returns the n-th Fibonacci number. -func Fibonacci(n uint) (uint64, error) { - if n <= 1 { - return uint64(n), nil - } +import ( + "github.com/gin-gonic/gin" + "math/rand" + "net/http" +) - var n2, n1 uint64 = 0, 1 - for i := uint(2); i < n; i++ { - n2, n1 = n1, n1+n2 - } +func main() { + r := gin.Default() - return n2 + n1, nil + r.GET("/rolldice", func(c *gin.Context) { + c.AsciiJSON(http.StatusOK, rand.Intn(5)+1) + }) + + r.Run() } + ``` With your core logic added, you can now build your application around it. Add a