31 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

[Check out the exercise and its solution here.](https://github.com/inancgumus/learngo/tree/master/05-write-your-first-library-package/exercise)
---
2018-10-13 23:30:21 +03:00
# EXERCISE
1. Create a new library
2018-11-18 05:03:43 +08:00
2. In it, create a function that returns the Go version
2018-10-13 23:30:21 +03:00
3. Create a command and import your library
4. Call your function that returns Go version
5. Run your program
## HINTS
**Create your package function like this:**
```go
func Version() string {
return runtime.Version()
}
```
## EXPECTED OUTPUT
It should print the current Go version on your system.
## WARNING
2018-11-18 05:03:43 +08:00
You should create this package under your own folder, not in github.com/inancgumus/learngo folder. Also, please note that VS Code may automatically import my library which is in github.com/inancgumus/learngo instead of your own library.
2018-11-18 05:03:43 +08:00
So, if you want VS Code automatically import your own package when you save, just move github.com/inancgumus/learngo out of GOPATH to somewhere else, for example, to your Desktop (of course move it back afterward).
2018-11-18 05:03:43 +08:00
See [this question](https://www.udemy.com/learn-go-the-complete-bootcamp-course-golang/learn/v4/questions/5518190) in Q&A for more information.