Addfunction to try things out. Create a test file called
adder_test.goand write this code.
%das our format strings rather than
%q. That's because we want it to print an integer rather than a string.
integers, as the name suggests this will group functions for working with integers such as
./adder_test.go:6:9: undefined: Add
(x int, y int)you can shorten it to
(x, y int).
adder_test.go:10: expected '4' but got '0'
Addfunction will add the parameters. You can refer this wiki for more details.
_test.gofiles. Add the following
ExampleAddfunction to the
adder_test.go. It is strongly recommended you research how to have these kind of errors fixed for you automatically in whatever editor you are using.)
// Output: 6. Although the function will be compiled, it won't be executed.
godoc, making your code even more accessible.
godoc -http=:6060and navigate to