Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions 24buildapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ func serveHome(w http.ResponseWriter, r *http.Request) {

func getAllCourses(w http.ResponseWriter, r *http.Request) {
fmt.Println("Get all courses")
w.Header().Set("Content-Type", "applicatioan/json")
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(courses)
}

func getOneCourse(w http.ResponseWriter, r *http.Request) {
fmt.Println("Get one course")
w.Header().Set("Content-Type", "applicatioan/json")
w.Header().Set("Content-Type", "application/json")

// grab id from request
params := mux.Vars(r)
Expand All @@ -88,7 +88,7 @@ func getOneCourse(w http.ResponseWriter, r *http.Request) {

func createOneCourse(w http.ResponseWriter, r *http.Request) {
fmt.Println("Create one course")
w.Header().Set("Content-Type", "applicatioan/json")
w.Header().Set("Content-Type", "application/json")

// what if: body is empty
if r.Body == nil {
Expand Down Expand Up @@ -120,7 +120,7 @@ func createOneCourse(w http.ResponseWriter, r *http.Request) {

func updateOneCourse(w http.ResponseWriter, r *http.Request) {
fmt.Println("Update one course")
w.Header().Set("Content-Type", "applicatioan/json")
w.Header().Set("Content-Type", "application/json")

// first - grab id from req
params := mux.Vars(r)
Expand All @@ -143,7 +143,7 @@ func updateOneCourse(w http.ResponseWriter, r *http.Request) {

func deleteOneCourse(w http.ResponseWriter, r *http.Request) {
fmt.Println("Delete one course")
w.Header().Set("Content-Type", "applicatioan/json")
w.Header().Set("Content-Type", "application/json")

params := mux.Vars(r)

Expand Down
4 changes: 2 additions & 2 deletions 27mutexAndAwaitGroups/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func main() {

var score = []int{0}

wg.Add(3)
wg.Add(4)
go func(wg *sync.WaitGroup, m *sync.RWMutex) {
fmt.Println("One R")
mut.Lock()
Expand All @@ -37,7 +37,7 @@ func main() {
wg.Done()
}(wg, mut)
go func(wg *sync.WaitGroup, m *sync.RWMutex) {
fmt.Println("Three R")
fmt.Println("Reading Scores")
mut.RLock()
fmt.Println(score)
mut.RUnlock()
Expand Down
10 changes: 5 additions & 5 deletions 28channels/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ func main() {
// R ONLY
go func(ch <-chan int, wg *sync.WaitGroup) {

val, isChanelOpen := <-myCh
val, isChanelOpen := <-ch

fmt.Println(isChanelOpen)
fmt.Println(val)

//fmt.Println(<-myCh)
//fmt.Println(<-ch)

wg.Done()
}(myCh, wg)
// send ONLY
go func(ch chan<- int, wg *sync.WaitGroup) {
myCh <- 0
close(myCh)
// myCh <- 6
ch <- 0
close(ch)
// ch <- 6
wg.Done()
}(myCh, wg)

Expand Down