Empty Go Interfaces

When declaring function parameters in Go, you must type the incoming data. Here’s an example: package main import "fmt" func print_stuff(s string) { fmt.Println(s) } func main() { print_stuff("Passing string!") } s string indicates that we’re passing a variable of type string into the function. This prevents us from from passing into variables of any other type. For example, this will fail with ./prog.go:10:17: cannot use 42 (type untyped int) as type string in argument to example_str if you try to pass an integer. ...

2021-07-11

golang

go doc Run web server: godoc -http=localhost:8888 -index -links View web server: http://localhost:8888 Tip: Add ?m=all to URL to show unexported types, funcs, etc. go test Run all tests: Run all tests: go test ./... Run all tests in package: go test modulename/pkg/packagename/ Run all tests in file: go test path/to/file_test.go Run subset of tests: Run function tests: go test path/to/file_test.go -run FUNCTION_TEST_NAME Run a single test in function tests: go test path/to/file_test.go -run FUNCTION_TEST_NAME/test_name_here Tips: ...