Go Developing for Multiple Platforms with Conditional Compiling Defining separate behaviours in different platforms

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 Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Different platforms can have separate implementations of the same method. This example also illustrates how build tags and file suffixes can be used together.

File main.go:

package main

import "fmt"

func main() {
    fmt.Println("Hello World from Conditional Compilation Doc!")
    printDetails()
}

details.go:

// +build !windows

package main

import "fmt"

func printDetails() {
    fmt.Println("Some specific details that cannot be found on Windows")
}

details_windows.go:

package main

import "fmt"

func printDetails() {
    fmt.Println("Windows specific details")
}


Got any Go Question?