1. Communicating on the Web

Instagram would be pretty terrible if you had to manually copy your photos to your friend's phone when you wanted to share them. Modern applications need to be able to communicate information between devices over the internet.

  • Gmail doesn't just store your emails in variables on your computer, it stores them on computers in their data centers

  • You don't lose your Slack messages if you drop your computer in a lake, those messages exist on Slack's serversarrow-up-right

How Does Web Communication Work?

When two computers communicate with each other, they need to use the same rules. An English speaker can't communicate verbally with a Japanese speaker, similarly, two computers need to speak the same language to communicate.

This "language" that computers use is called a protocolarrow-up-right. The most popular protocol for web communication is HTTParrow-up-right, which stands for Hypertext Transfer Protocol.

Jello

Throughout this course, we'll be building parts of an online issue tracking app called "Jello". It's a typical issue tracker with one key difference: this time it's good, actually.

Assignment

Take a look at the getIssueData function that I've provided in http.go. It retrieves information about issues from Jello's servers via HTTP as a slice of bytes []byte.

In main.go do the following:

1

Convert bytes to string

Convert the slice of bytes to a string with the built-in string() type conversionarrow-up-right.

2

Print the string representation of the bytes to the console.

It should look like a long, unformatted string of text representing raw issue data.

circle-info

Notice how none of the data that is logged to the console was generated within our code! That's because the data we retrieved is being sent over the internet from our servers via HTTP.

Assignment / Solution

main.go
package main

import (
	"fmt"
	"log"
)

func main() {
	issues, err := getIssueData()
	if err != nil {
		log.Fatalf("error getting issue data: %v", err)
	}

	// Don't edit above this line
	bytes := string(issues)

	fmt.Println(bytes)
	
}