Go Getting started with Go FizzBuzz

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Another example of "Hello World" style programs is FizzBuzz. This is one example of a FizzBuzz implementation. Very idiomatic Go in play here.

package main

// Simple fizzbuzz implementation

import "fmt"

func main() {
    for i := 1; i <= 100; i++ {
        s := ""       
        if i % 3 == 0 {
            s += "Fizz"
        }
        if i % 5 == 0 {
            s += "Buzz"
        }
        if s != "" {
            fmt.Println(s) 
        } else {
            fmt.Println(i) 
        }
    }
}

Playground



Got any Go Question?