Skip to content

Latest commit

 

History

History
71 lines (48 loc) · 2.23 KB

README.md

File metadata and controls

71 lines (48 loc) · 2.23 KB

CLI Rescue exercise

Setup

  1. Start by forking this repo so you have your own copy.
  2. clone the repo in your Go path:
go get github.com/$github_user/clirescue.git
cd $GOPATH/src/github.com/clirescue

Install the dependencies:

go get github.com/codegangsta/cli

Load the project into your editor and do a search and replace:

  • Replace: github.com/GoBootcamp
  • With: github.com/<github-username>

Commit the change:

git commit -a -m "forking repo requires internal code changes"

If everything is properly setup, you should be able to run your code:

go run main.go me

You can use the following demo Pivotal Tracker account:

  • Username: gobootcamp
  • Password: santamonica

Start rescuing

This code was written by someone who just started learning Go. Beginners often make the same mistakes so assume that this is your code and you are now tasked to refactor it. The end goal is to create a CLI to interface with the Pivotal Tracker API.

The current code is asking the user for a username and password, the user details are fetched. Your first step might be to store the user token on the drive so next time the program is called, it can automatically load the user details be without asking for the user's username and password.

A few hints:

  • Understanding Go path's system might be a bit tricky at first.
  • Forking the repo might affect your import statements.
  • The original author might not have made a good use of packages.
  • You more thna likely have some OOP experience, you might want to leverage it in this exercise.
  • Checkout the init function.
  • Curious about how a 3rd party lib works? Try go doc.
  • Simpler is better.
  • Look into how to write tests.
  • Bonus point for removing 3rd part dependencies.

As always, refer to the Effective Go doc and the go bootcamp book if you have any questions.

Existing refactors