Created
November 2, 2023 07:13
-
-
Save nbbrdn/277b54f35e48320093576443e2b5111b to your computer and use it in GitHub Desktop.
Minimal Go Web Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
func main() { | |
server := &http.Server{ | |
Addr: ":3000", | |
Handler: http.HandlerFunc(basicHandler), | |
} | |
err := server.ListenAndServe() | |
if err != nil { | |
fmt.Println("failed to listen to server", err) | |
} | |
} | |
func basicHandler(w http.ResponseWriter, r *http.Request) { | |
w.Write([]byte("Hello, world!")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment