Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b87ccabca3 |
3 changed files with 36 additions and 3 deletions
16
README.md
16
README.md
|
|
@ -1,6 +1,16 @@
|
|||
# Hello (World) Learning
|
||||
# Hello Go
|
||||
|
||||
A place for me to play around with some basic example apps, most commonly "Hello World"'s and "TODO" examples.
|
||||
```bash
|
||||
go run hello-world.go
|
||||
```
|
||||
|
||||
**Each language/framework is broken down by branch.**
|
||||
Prints: `Hello World`
|
||||
|
||||
---
|
||||
|
||||
```bash
|
||||
go run hello-world-server.go
|
||||
```
|
||||
|
||||
Launches a webserver
|
||||
|
||||
|
|
|
|||
16
hello-world-server.go
Normal file
16
hello-world-server.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", homepage)
|
||||
fmt.Println("Server is running on http://localhost:8081")
|
||||
http.ListenAndServe(":8081", nil)
|
||||
}
|
||||
|
||||
func homepage(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "<h1>Hello World</h1>")
|
||||
}
|
||||
7
hello-world.go
Normal file
7
hello-world.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello World!")
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue