Go Here Go, .
- department
- term
- GE
- courseNum
- courseCodes
- instructorName
- units
- endTime
- startTime
- fullCourses
- building
func getResult(w http.ResponseWriter, r *http.Request) {
result := MakeRequest()
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(result.Schools.Schools)
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/api/", getResult).Methods("GET")
//run on local
log.Fatal(http.ListenAndServe(":8000", r))
fmt.Println("Hello")
}
Get Mux router library first Type in and enter "go get -u github.com/gorilla/mux" in the terminal
Remember to import Mux library
import (
"github.com/gorilla/mux"
)
Two options to run:
- Type in and enter "go run main.go" to run without compiling the program first.
- Type in and enter "go build" then "./nameOftheProgram" to run with compiling.