Skip to content

Commit

Permalink
Golang Getting started - based on roll dice service and Automatic Ins…
Browse files Browse the repository at this point in the history
…trumentation
  • Loading branch information
pegasas committed Sep 9, 2023
1 parent 1ea0f60 commit 6395b7e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions content/en/docs/instrumentation/go/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6395b7e

Please sign in to comment.