ssilva / gomoduletest

Testing the new Go 1.11 modules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go Module Test

  1. Have the following in gomoduletest-cmd/main.go:
    package main
    
    import (
      "fmt"
      "github.com/ssilva/gomoduletest"
    )
    
    func main() {
      fmt.Println(gomoduletest.Greet(""))
      fmt.Println(gomoduletest.Greet("John"))
    }
  2. Enable modules.
    $ cd gomoduletest-cmd
    $ go mod init cmd
    go: creating new go.mod: module cmd
    
  3. Run it
    $ go run main.go
    Hello, World!
    Hello, John!
    
  4. Get a specific version of the module
    $ go get github.com/ssilva/gomoduletest@v1.0.0
    $ go run main.go
    Hello, !
    Hello, John!
    

Source: https://roberto.selbach.ca/intro-to-go-modules/

About

Testing the new Go 1.11 modules


Languages

Language:Go 100.0%