19. Special Features
Activity 19.01: Defining Build Constraints Using Filenames
Solution:
- Create a directory called
custom
. - Inside this directory, create a file called
print_darwin.go
. - Define a function called
Print()
:package custom import "fmt" func Print() { Â Â fmt.Println("Hello I am running on a darwin machine.") }
- Create another file inside the
custom
directory calledprint_386.go
. - Define a function inside this package called
Print()
:import "fmt" func Print() { Â Â fmt.Println("Hello I am running on 386 machine.") }
- Run the program using the following command:
go run main.go
You should see the following output:
$ go run main.go Hello I am running on a darwin machine.
Activity 19.02: Using Wildcard with Go Test
Solution:
- Create a directory called
package1
: - Create
run_test.go
in this directory with the following test cases defined:package package1...