

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 write a package to import and use in hellogo.
cd ..
mkdir mystrings
cd mystrings
go mod init {REMOTE}/{USERNAME}/mystrings
// by convention, we name our package the same as the directory
package mystrings
// Reverse reverses a string left to right
// Notice that we need to capitalize the first letter of the function
// If we don't then we won't be able to access this function outside of the
// mystrings package
func Reverse(s string) string {
result := ""
for _, v := range s {
result = string(v) + result
}
return result
}
Only capitalized names are exported, meaning they can be accessed by other packages. Uncapitalized names are private.
Run and submit the CLI tests from the root of the mystrings package.