commit 414642145ffde36ed438b6e23d34477f6258925a Author: Antonio De Lucreziis Date: Mon Mar 14 12:03:49 2022 +0100 Initial commit diff --git a/esempio/esempio.go b/esempio/esempio.go new file mode 100644 index 0000000..9cfedc1 --- /dev/null +++ b/esempio/esempio.go @@ -0,0 +1,37 @@ +package main + +import "fmt" + +type Veicolo interface { + parti() +} + +type Macchina struct { + NumeroPorte int + Propietario string +} + +func (m *Macchina) parti() { + fmt.Println("La macchina e' partita") +} + +type Camion struct { + Peso int + Propietario string +} + +func (m *Camion) parti() { + fmt.Println("Il camion e' partito") +} + +func muoviMezzo(v Veicolo) { + v.parti() +} + +func main() { + m := &Macchina{NumeroPorte: 5, Propietario: "Boh"} + muoviMezzo(m) + + c := &Camion{Peso: 1000, Propietario: "Boh"} + muoviMezzo(c) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..c1bcf21 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module phc.org/esempio + +go 1.17 diff --git a/index.html b/index.html new file mode 100644 index 0000000..b54f965 --- /dev/null +++ b/index.html @@ -0,0 +1,12 @@ + + + + + + + Prova + + +

PAgina!

+ + \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..3582923 --- /dev/null +++ b/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "net/http" +) + +func main() { + http.HandleFunc("/a", func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "./index.html") + }) + http.HandleFunc("/b", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("B")) + }) + + fmt.Println("Listening on port 8080") + err := http.ListenAndServe(":8080", nil) + if err != nil { + panic(err.Error()) + } + + fmt.Println("Stopped!") +}