Installing the MongoDB Go Driver
Resources
https://docs.mongodb.com/drivers/go/current/
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/
Official Go download page, this link gives you more option to choose from OS platform and OS architecture x86-64 build. And you can use the go build command parameter to building a binary for an application that can run for CPU of x86 (386) and x86-64.
Install
Open the MSI file you downloaded and follow the prompts to install Go. The default folder used is C:/go. Or choose any folder that Windows 10 security may not ask for an administrator password for install programs/files using that folder path.
System Environment variable created by MSI installer
GOPATH C:\Users\loginname\go
Note: loginname is the user name to Window login
PATH C:\Go\bin
Verify
Launch a windows terminal, type go version
go version go1.15.6 windows/amd64 output confirmed go installation has been successful. Otherwise, use the Windows Control panel app -> Programs find go1.15.6 has been program has been installed.
Troubleshooting
Google, Go forum, and Stackoverflow for assistance.
package main
import "fmt"
func main() {
kvs := map[string]string{"1":"shan kuo","2":"Hoi Leng","3":"Choi Yan","4":"Evelyn Chan"}
for k, v := range kvs {
fmt.Printf("%s -> %s\n",k,v)
}
}
https://repl.it/join/gdzplzna-shankuo
go build
./main
1 -> shan kuo
2 -> Hoi Leng
3 -> Choi Yan
4 -> Evelyn Chan
package main
import "fmt"
func main() {
names := []string{"Shank Kuo","Hoi Leng","Choi Yan","Evelyn Chan"}
for i:=0; i < len(names); i++ {
fmt.Println(names[i])
}
}
https://repl.it/@shankuo/LoopArraySlice
go version go1.14 linux/amd64
go run main.go
Shank Kuo
Hoi Leng
Choi Yan
Evelyn Chan
suffix with underscore with the filename. For example, the hello.go is the source file then hello.go with test package will have the filename hello_test.go tells the go
test command that this file contains test functions.
hello_test.go
Testing
packageImporting the testing package is a must to be included along with other imported packages such as the “fmt” package that it commonly in use.
import (
"testing"
)
Test
commandAt the command line where the source code directory, run the go test command to execute the test
go test
Expect results of the function
Prefix the Test to the function name. For example, TestHelloName()
// TestHelloName calls greetings.Hello with a name, checking // for a valid return value. func TestHelloName(t *testing.T) { name := "Gladys" want := regexp.MustCompile(`\b`+name+`\b`) msg, err := Hello("Gladys") if !want.MatchString(msg) || err != nil { t.Fatalf(`Hello("Gladys") = %q, %v, want match for %#q, nil`, msg, err, want) } }
Fyne is an easy to use UI toolkit and app API written in Go. It is designed to build applications that run on desktop and mobile devices with a single codebase.
The steps for installing with MSYS2 (recommended) are as follows:
$ pacman -Syu
$ pacman -S git mingw-w64-x86_64-toolchain
go get fyne.io/fyne
Resources