

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Packages
incomplete
2: Package Naming
incomplete
3: Install
incomplete
4: Modules
incomplete
5: Go Environment
incomplete
6: First Local Program
incomplete
7: Go Run
incomplete
8: Go Build
incomplete
9: Go Install
incomplete
10: Custom Package
incomplete
11: Custom Package Continued
incomplete
12: Remote Packages
incomplete
13: Clean Packages
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Let's learn how to import and use an open-source package that's available on GitHub.
Be aware that using the "replace" keyword like we did in the last assignment is not advised, but can be useful to get up and running quickly. The proper way to create and depend on modules is to publish them to a remote repository. When you do that, the "replace" keyword can be dropped from the go.mod:
This only works for local-only development:
replace github.com/wagslane/mystrings v0.0.0 => ../mystrings
If we want the import to work for everyone, we need to make sure the dependency (mystrings in this case) actually exists on https://github.com/wagslane/mystrings.
package main
import (
"fmt"
"time"
tinytime "github.com/wagslane/go-tinytime"
)
func main() {
tt := tinytime.New(1585750374)
tt = tt.Add(time.Hour * 48)
fmt.Println("1585750374 converted to a tinytime is:", tt)
}
go mod init {REMOTE}/{USERNAME}/datetest
go get github.com/wagslane/go-tinytime
cat go.mod
go build
./datetest
Run and submit the CLI tests from the root of the datetest package.