# Using Blogdown to blog about Golang

·
2 min read

For those of you interested I am blogging about Go using the R blogdown package. It works straight out of the box.

Basic example:

```
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}
```

```
## Hello World
```

another example:

```
package main
import (
"fmt"
"math"
)
func foo(x int) int {
return x * x
}
func main() {
for i := 0; i < 10; i++ {
v := float64(foo(i))
switch {
case math.Mod(v, 2) == 0:
fmt.Printf("%v is Even!!!\n", v)
default:
fmt.Printf("%v is Odd!!!\n", v)
}
}
}
```

```
## 0 is Even!!!
## 1 is Odd!!!
## 4 is Even!!!
## 9 is Odd!!!
## 16 is Even!!!
## 25 is Odd!!!
## 36 is Even!!!
## 49 is Odd!!!
## 64 is Even!!!
## 81 is Odd!!!
```

Blogdown is based on Hugo framework which is actually written in Go and support mulitple programming languages which you can mix and match:

```
names(knitr::knit_engines$get())
```

```
## [1] "awk" "bash" "coffee" "gawk" "groovy"
## [6] "haskell" "lein" "mysql" "node" "octave"
## [11] "perl" "psql" "Rscript" "ruby" "sas"
## [16] "scala" "sed" "sh" "stata" "zsh"
## [21] "highlight" "Rcpp" "tikz" "dot" "c"
## [26] "fortran" "fortran95" "asy" "cat" "asis"
## [31] "stan" "block" "block2" "js" "css"
## [36] "sql" "go" "python" "julia" "sass"
## [41] "scss" "theorem" "lemma" "corollary" "proposition"
## [46] "conjecture" "definition" "example" "exercise" "proof"
## [51] "remark" "solution"
```