From 88037849e184ff0ce0f3dbf1fc21ea2fe7d1e3ee Mon Sep 17 00:00:00 2001 From: Robert Stachecki Date: Tue, 20 Nov 2018 21:30:03 +0000 Subject: [PATCH] =?UTF-8?q?Prze=C5=9Blij=20pliki=20do=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- serwer.go | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 serwer.go diff --git a/serwer.go b/serwer.go new file mode 100644 index 0000000..f2a0cd6 --- /dev/null +++ b/serwer.go @@ -0,0 +1,11 @@ +func main() { +db := database{"buty": 50, "skarpety": 5} +log.Fatal(http.ListenAndServe("localhost:8000", db)) +} +type dollars float32 +func (d dollars) String() string { return fmt.Sprintf("%.2f PLN", d) } +type database map[string]dollars +func (db database) ServeHTTP(w http.ResponseWriter, req *http.Request) { +for item, price := range db { +fmt.Fprintf(w, "%s: %s\n", item, price) +}