- Define how concurrency works in Golang.
- Build an interactive slackbot using goroutines.
Present Learning Go's Concurrency Through Illustrations.
- Source: link
Before Starting: Brainstorm command(s) you'd like your Slackbot to perform.
- Have these docs open and ready as you configure a Slack Bot User.
- Point your browser to the Create a Slack App page.
- Enter a name that fits the problem you're trying to solve.
- Select Product College workspace from the Workspace drop-down.
- Click the Create App button.
- On the sidebar, under the Features header, click Bot Users.
- Git your bot a display name and a default username.
- Click the Save Changes button.
- Go to OAuth & Permissions and scroll down to the Scopes > Select Permission Scopes text entry field.
- Add
channels:history
,channels:read
, andchannels:write
permission scope and click Save Changes. - Click Install App to Workplace, and make sure you set the contents of the dialog to match the below screenshot. This ensures your bot replies in a particular channel:
#golang-slackbots
. Make sure your OAuth dialog matches the following:
- Fork this starter repo.
- It is best if you work from one computer today.
- Clone the forked repo to your local machine and
cd REPO_NAME
. - Create a
.env
file by runningcp .env.sample .env
. - Paste the Bot Token from Step 9 in
.env
afterBOT_OAUTH_ACCESS_TOKEN=
. - Run
go run main.go
to start the server.- If it fails to start, let the instructor know.
If you get stuck, the following tutorial can assist: Writing Slackbots with Goroutines
- There are 3 challenges written in the project's comments.
- Search the project for
TODO
in order to find them.
- Search the project for
- Complete each with the help of your team.
- Examine the output of
go run main.go
. - Manually test the bot via Slack while completing the activity.
- Examine the output of
- An additional stretch challenge is available if you finish early.
Deploying your bot means it will run forever --- even when your computer isn't on!
Use this sample script to deploy your bot to Heroku:
$ git clone git@github.com:USERNAME/goslackit.git PROJECT_NAME
$ cd PROJECT_NAME
$ heroku create PROJECT_NAME
$ heroku config:set BOT_OAUTH_ACCESS_TOKEN=YOUR_BOT_TOKEN
$ git push heroku master
$ heroku ps:scale worker=1
- The Go Blog: Go Modules in 2019
- Golang Bootcamp: Concurrency chapter. Be sure to execute the code samples!
- (2012) OG Golang Talk: Concurrency is not Parallelism: Slide deck by Rob Pike.
- Learn Go with Tests
- A Complete Journey with Goroutines
- Concurrency in Go: Visualization with Example: Awesome visualization that implements a goroutine.