{"id":13714075,"url":"https://github.com/shoeb240/first-go-api","last_synced_at":"2026-03-05T21:30:08.197Z","repository":{"id":73379981,"uuid":"162582108","full_name":"shoeb240/first-go-api","owner":"shoeb240","description":"Creating first go api project as I am learning golang","archived":false,"fork":false,"pushed_at":"2018-12-21T06:23:07.000Z","size":4,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-03T23:29:36.391Z","etag":null,"topics":["api","go","golang","gorilla-mux","rest-api","restful-api"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shoeb240.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-20T13:17:27.000Z","updated_at":"2019-01-25T14:10:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"c4d83e95-41d3-461b-91d2-3ffafd820c49","html_url":"https://github.com/shoeb240/first-go-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shoeb240%2Ffirst-go-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shoeb240%2Ffirst-go-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shoeb240%2Ffirst-go-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shoeb240%2Ffirst-go-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shoeb240","download_url":"https://codeload.github.com/shoeb240/first-go-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224551157,"owners_count":17330086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","go","golang","gorilla-mux","rest-api","restful-api"],"created_at":"2024-08-02T23:01:51.130Z","updated_at":"2026-03-05T21:30:08.144Z","avatar_url":"https://github.com/shoeb240.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# Creating simplest API in GO\n\n## Download and Install Go\nhttps://golang.org/dl/\n\n## Directory Structure\nCreate a folder 'go' at your home directory as $HOME/go is the default $GOPATH. Create 'src' and 'bin' directory within 'go' directory. Packages reside inside 'src' directory. \n\nNow, run the follwoing command to get this project with all dependency packages:\n```cgo\ngo get github.com/shoeb240/first-go-api\n```\n\nOR\n\nCreate the following directory structure within $HOME/go directory:\n\n```cgo\nbin/\nsrc/\n    github.com/shoeb240/\t\n```\n\ncd to src/github.com/shoeb240/ and clone this project from github with the following git command:\n```cgo\ngit clone http://github.com/shoeb240/first-go-api\n```\n\nTo download Gorilla Mux pacjake run the following command:\n```cgo\ngo get github.com/gorilla/mux\n```\n\n\nNow, you will have the following directory structure:\n```cgo\nbin/\nsrc/\n    github.com/gorilla/\n\t    mux/\n    github.com/shoeb240/\n\t    first-go-api/\n\t        main.go               # command source\n\t        route.go               \n\t        handlers.go               \n```\n\n## route.go\nCreating api route '/users' and opening port 8081 to listen to request using gorilla mux\n\n```go\npackage main\n\nimport (\n    \"github.com/gorilla/mux\"\n    \"net/http\"\n)\n\nfunc RequestHandle() {\n    myRouter := mux.NewRouter()\n    myRouter.HandleFunc(\"/users\", getUsers).Methods(\"GET\")\n\n    http.ListenAndServe(\":8081\", myRouter)\n}\n```\n\n## handlers.go\nCreating getUsers handler method to respond to the route\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"net/http\"\n)\n\nfunc getUsers(w http.ResponseWriter, r *http.Request) {\n    fmt.Fprintf(w, \"Showing users list\")\n}\n```\n\n## main.go\nCalling RequestHandle() from main\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n)\n\nfunc main(){\n    fmt.Println(\"Waiting for request to serve...\")\n    RequestHandle()\n}\n```\n\nRun the following command\n```\ngo run github.com/shoeb240/first-go-api\n```\n\nIt will output\n```\nWaiting for request to serve...\n```\n\nOpen your browser to open url 'localhost:8081/users'. It will show..\n```\nI am responding to your API call\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshoeb240%2Ffirst-go-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshoeb240%2Ffirst-go-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshoeb240%2Ffirst-go-api/lists"}