diff --git a/interfaces/01-methods/book.go b/interfaces/01-methods/book.go new file mode 100644 index 0000000..a001e71 --- /dev/null +++ b/interfaces/01-methods/book.go @@ -0,0 +1,36 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +type book struct { + title string + price float64 +} + +func (b book) print() { + // b is a copy of the original `book` value here. + fmt.Printf("%-15s: $%.2f \n", b.title, b.price) +} + +// ---------------------------------------------------------------------------- +// + you can use the same method names among different types. +// + you don't need to type `printGame`, it's just: `print`. +// +// func (b book) printBook() { +// // b is a copy of the original `book` value here. +// fmt.Printf("%-15s: $%.2f \n", b.title, b.price) +// } + +// ---------------------------------------------------------------------------- +// b is a copy of the original `book` value here. +// +// func printBook(b book) { +// fmt.Printf("%-15s: $%.2f \n", b.title, b.price) +// } diff --git a/interfaces/01-methods/game.go b/interfaces/01-methods/game.go new file mode 100644 index 0000000..6a8efe6 --- /dev/null +++ b/interfaces/01-methods/game.go @@ -0,0 +1,36 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +type game struct { + title string + price float64 +} + +func (g game) print() { + fmt.Printf("%-15s: $%.2f\n", g.title, g.price) +} + +// PREVIOUS CODE: + +// ---------------------------------------------------------------------------- +// you can use same method name among different types. +// you don't need to type `printGame`, it's just: `print`. +// +// func (g game) printGame() { +// fmt.Printf("%-15s: $%.2f\n", g.title, g.price) +// } + +// ---------------------------------------------------------------------------- +// you cannot use the same function name within the same package. +// +// func printGame(g game) { +// fmt.Printf("%-15s: $%.2f\n", g.title, g.price) +// } diff --git a/interfaces/01-methods/main.go b/interfaces/01-methods/main.go new file mode 100644 index 0000000..dc3a19b --- /dev/null +++ b/interfaces/01-methods/main.go @@ -0,0 +1,46 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +func main() { + mobydick := book{ + title: "moby dick", + price: 10, + } + + minecraft := game{ + title: "minecraft", + price: 20, + } + + tetris := game{ + title: "tetris", + price: 5, + } + + // #4: method expressions + // methods are just functions that receive a value of a type. + game.print(minecraft) // sends `minecraft` value to `game.print` + game.print(tetris) // sends `tetris` value to `game.print` + fmt.Println() + + // #3 + mobydick.print() // sends `mobydick` value to `book.print` + minecraft.print() // sends `minecraft` value to `game.print` + tetris.print() // sends `tetris` value to `game.print` + + // #2 + // mobydick.printBook() + // minecraft.printGame() + + // #1 + // printBook(mobydick) + // printGame(minecraft) +} diff --git a/interfaces/02-receivers/book.go b/interfaces/02-receivers/book.go new file mode 100644 index 0000000..7b925aa --- /dev/null +++ b/interfaces/02-receivers/book.go @@ -0,0 +1,20 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +type book struct { + title string + price float64 +} + +func (b book) print() { + // b is a copy of the original `book` value here. + fmt.Printf("%-15s: $%.2f \n", b.title, b.price) +} diff --git a/interfaces/02-receivers/game.go b/interfaces/02-receivers/game.go new file mode 100644 index 0000000..dcaf1cf --- /dev/null +++ b/interfaces/02-receivers/game.go @@ -0,0 +1,34 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +type game struct { + title string + price float64 +} + +func (g *game) print() { + fmt.Printf("%-15s: $%.2f\n", g.title, g.price) +} + +// + discount gets a copy of `*game`. +// + discount can update the original `game` through the game pointer. +// + it's better to use the same receiver type: `*game` for all methods. +func (g *game) discount(ratio float64) { + g.price *= (1 - ratio) +} + +// PREVIOUS CODE: + +// ---------------------------------------------------------------------------- +// + `g` is a copy: `discount` cannot change the original `g`. +// func (g game) discount(ratio float64) { +// g.price *= (1 - ratio) +// } diff --git a/interfaces/02-receivers/list.go b/interfaces/02-receivers/list.go new file mode 100644 index 0000000..da097a3 --- /dev/null +++ b/interfaces/02-receivers/list.go @@ -0,0 +1,28 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +// + you can attach methods to any concrete type. +// + rule: you need to declare a new type in the same package. +type list []game + +func (l list) print() { + // `list` acts like a `[]game` + if len(l) == 0 { + fmt.Println("Sorry. Our store is closed. We're waiting for the delivery 🚚.") + return + } + + fmt.Printf("My Store:\n") + fmt.Printf("---------\n") + for _, it := range l { + it.print() + } +} diff --git a/interfaces/02-receivers/main.go b/interfaces/02-receivers/main.go new file mode 100644 index 0000000..deba14e --- /dev/null +++ b/interfaces/02-receivers/main.go @@ -0,0 +1,27 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +func main() { + var ( + // mobydick = book{title: "moby dick", price: 10} + minecraft = game{title: "minecraft", price: 20} + tetris = game{title: "tetris", price: 5} + ) + + var items []game + items = append(items, minecraft, tetris) + + // you can attach methods to a compatible type on the fly: + my := list([]game{minecraft, tetris}) + + // you can call methods even on a nil value + // my = nil + + my.print() // or: list.print(items) +} diff --git a/interfaces/03-interfaces/book.go b/interfaces/03-interfaces/book.go new file mode 100644 index 0000000..7b925aa --- /dev/null +++ b/interfaces/03-interfaces/book.go @@ -0,0 +1,20 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +type book struct { + title string + price float64 +} + +func (b book) print() { + // b is a copy of the original `book` value here. + fmt.Printf("%-15s: $%.2f \n", b.title, b.price) +} diff --git a/interfaces/03-interfaces/game.go b/interfaces/03-interfaces/game.go new file mode 100644 index 0000000..dcaf1cf --- /dev/null +++ b/interfaces/03-interfaces/game.go @@ -0,0 +1,34 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +type game struct { + title string + price float64 +} + +func (g *game) print() { + fmt.Printf("%-15s: $%.2f\n", g.title, g.price) +} + +// + discount gets a copy of `*game`. +// + discount can update the original `game` through the game pointer. +// + it's better to use the same receiver type: `*game` for all methods. +func (g *game) discount(ratio float64) { + g.price *= (1 - ratio) +} + +// PREVIOUS CODE: + +// ---------------------------------------------------------------------------- +// + `g` is a copy: `discount` cannot change the original `g`. +// func (g game) discount(ratio float64) { +// g.price *= (1 - ratio) +// } diff --git a/interfaces/03-interfaces/list.go b/interfaces/03-interfaces/list.go new file mode 100644 index 0000000..1c9c2e9 --- /dev/null +++ b/interfaces/03-interfaces/list.go @@ -0,0 +1,33 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +type printer interface { + print() +} + +type list []printer + +func (l list) print() { + if len(l) == 0 { + fmt.Println("Sorry. Our store is closed. We're waiting for the delivery 🚚.") + return + } + + fmt.Printf("My Store:\n") + fmt.Printf("---------\n") + for _, it := range l { + it.print() + + // you cannot access to the discount method of the game type. + // `it` is a printer not a game. + // it.discount(.5) + } +} diff --git a/interfaces/03-interfaces/main.go b/interfaces/03-interfaces/main.go new file mode 100644 index 0000000..0e80a9e --- /dev/null +++ b/interfaces/03-interfaces/main.go @@ -0,0 +1,52 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +func main() { + var ( + mobydick = book{title: "moby dick", price: 10} + minecraft = game{title: "minecraft", price: 20} + tetris = game{title: "tetris", price: 5} + rubik = puzzle{title: "rubik's cube", price: 5} + ) + + var store list + + store = append(store, &minecraft, &tetris, mobydick, rubik) + + tetris.discount(.8) + // printer(tetris).discount(.8) + + store.print() +} + +/* +var my list + +// + only the `*game` have methods. +// + `game` doesn't have any methods. +// + `item` interface couldn't be satisfied with a `game` value. +// + it can only be satisfied with a `*game` value. +// my = my.add(minecraft) +my = append(my, &minecraft) +my = append(my, &tetris) +my = append(my, &mobydick) + +// interface value stores a pointer to minecraft +minecraft.discount(.5) +my.list() + +my.discount(.5) +my.list() +*/ + +// ! cannot add mobydick to the store: it's a book type, not a game type. +// interfaces to the rescue! +// mobydick := book{title: "moby dick", price: 10} +// my.add(&mobydick) +// ---------------------------------------------------------------- diff --git a/interfaces/03-interfaces/puzzle.go b/interfaces/03-interfaces/puzzle.go new file mode 100644 index 0000000..09f5156 --- /dev/null +++ b/interfaces/03-interfaces/puzzle.go @@ -0,0 +1,19 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +type puzzle struct { + title string + price float64 +} + +func (p puzzle) print() { + fmt.Printf("%-15s: $%.2f \n", p.title, p.price) +} diff --git a/interfaces/04-interfaces/book.go b/interfaces/04-interfaces/book.go new file mode 100644 index 0000000..4cfccba --- /dev/null +++ b/interfaces/04-interfaces/book.go @@ -0,0 +1,24 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +type book struct { + title string + price float64 +} + +func (b book) print() { + fmt.Printf("%-15s: $%.2f \n", b.title, b.price) +} + +// TODO: NEW +func (b book) total() float64 { + return b.price +} diff --git a/interfaces/04-interfaces/game.go b/interfaces/04-interfaces/game.go new file mode 100644 index 0000000..7cbe528 --- /dev/null +++ b/interfaces/04-interfaces/game.go @@ -0,0 +1,28 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +type game struct { + title string + price float64 +} + +func (g *game) print() { + fmt.Printf("%-15s: $%.2f\n", g.title, g.price) +} + +func (g *game) discount(ratio float64) { + g.price *= (1 - ratio) +} + +// TODO: NEW +func (g *game) total() float64 { + return g.price +} diff --git a/interfaces/04-interfaces/list.go b/interfaces/04-interfaces/list.go new file mode 100644 index 0000000..86a0156 --- /dev/null +++ b/interfaces/04-interfaces/list.go @@ -0,0 +1,71 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import "fmt" + +// TODO: NEW +type printer interface { + print() +} + +// TODO: NEW +type pricer interface { + total() float64 +} + +// TODO: NEW +// interface embedding +type item interface { + printer + pricer +} + +// a slice of item interface values +type list []item + +func (l list) list() { + // `list` acts like a `[]game` + if len(l) == 0 { + fmt.Println("Sorry. Our store is closed. We're waiting for the delivery 🚚.") + return + } + + fmt.Printf("My Store:\n") + fmt.Printf("---------\n") + for _, it := range l { + it.print() + } + + // TODO: NEW + fmt.Printf("\nGROSS: $%.2f\n", l.total()) +} + +// TODO: NEW +func (l list) total() (gross float64) { + for _, it := range l { + gross += it.total() + } + return gross +} + +// TODO: NEW +func (l list) discount(ratio float64) { + type discounter interface { + discount(float64) + } + + for _, it := range l { + dit, ok := it.(discounter) + if !ok { + continue + } + + dit.discount(ratio) + } +} diff --git a/interfaces/04-interfaces/main.go b/interfaces/04-interfaces/main.go new file mode 100644 index 0000000..b3ac142 --- /dev/null +++ b/interfaces/04-interfaces/main.go @@ -0,0 +1,35 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +func main() { + var ( + minecraft = game{title: "minecraft", price: 20} + tetris = game{title: "tetris", price: 5} + mobydick = book{title: "moby dick", price: 10} + ) + + var my list + // my.list() // nil receiver is a valid value + + // + only the `*game` have methods. + // + `game` doesn't have any methods. + // + `item` interface couldn't be satisfied with a `game` value. + // + it can only be satisfied with a `*game` value. + // my = my.add(minecraft) + my = append(my, &minecraft) + my = append(my, &tetris) + my = append(my, &mobydick) + + // interface value stores a pointer to minecraft + minecraft.discount(.5) + my.list() + + my.discount(.5) + my.list() +} diff --git a/interfaces/05-log-parser/01-methods/changes.md b/interfaces/05-log-parser/01-methods/changes.md new file mode 100644 index 0000000..670639d --- /dev/null +++ b/interfaces/05-log-parser/01-methods/changes.md @@ -0,0 +1,36 @@ +# Problem + +## All these functions operate on a *parser value: ++ `main.go`: + + `summarize(*p parser)` ++ `parser.go`: + + `func parse(p *parser, line string) (r result)` + + `func update(p *parser, r result)` + + `func err(p *parser) error` + +## What is an object in Go? ++ Object = A value of a type : `&parser{}` is an object. + + `type parser struct` is the definition (class/blueprint) of the object. + +### Methods are behaviors of objects: ++ Parser needs to parse, update (analyse) the parsings, and report an error if any. ++ Parser also needs to summarize the results. ++ So, all these functions belong to a parser object. + +# Solution + ++ Attach the functions to the parser using methods. ++ Methods are the behavior of the parser. ++ Keep the methods that belong to a single type in the same file. + +1. Move the `summarize` into `parser.go`. +2. `parser.go`: Use methods. +3. `main()` : Use methods of the `parser`. + +# Convince + ++ `p.` shows the fields and methods belong to the `parser`. ++ `p.` selects a method from the method set of the `parser`. ++ `p.method` sends the `p` as the first parameter to the method. ++ `p` is the receiver: `*pointer`. It's a pointer receiver. ++ Receiver is copied to the method. \ No newline at end of file diff --git a/interfaces/05-log-parser/01-methods/log.txt b/interfaces/05-log-parser/01-methods/log.txt new file mode 100644 index 0000000..940b832 --- /dev/null +++ b/interfaces/05-log-parser/01-methods/log.txt @@ -0,0 +1,16 @@ +learngoprogramming.com 10 +learngoprogramming.com 15 +learngoprogramming.com 10 +learngoprogramming.com 20 +learngoprogramming.com 5 +golang.org 40 +golang.org 20 +golang.org 45 +golang.org 15 +blog.golang.org 60 +blog.golang.org 30 +blog.golang.org 20 +blog.golang.org 65 +blog.golang.org 15 +inanc.io 30 +inanc.io 70 \ No newline at end of file diff --git a/interfaces/05-log-parser/01-methods/log_err_missing.txt b/interfaces/05-log-parser/01-methods/log_err_missing.txt new file mode 100644 index 0000000..9169c91 --- /dev/null +++ b/interfaces/05-log-parser/01-methods/log_err_missing.txt @@ -0,0 +1,16 @@ +learngoprogramming.com 10 +learngoprogramming.com 15 +learngoprogramming.com 10 +learngoprogramming.com 20 +learngoprogramming.com +golang.org 40 +golang.org 20 +golang.org 45 +golang.org 15 +blog.golang.org 60 +blog.golang.org 30 +blog.golang.org 20 +blog.golang.org 65 +blog.golang.org 15 +inanc.io 30 +inanc.io 70 \ No newline at end of file diff --git a/interfaces/05-log-parser/01-methods/log_err_negative.txt b/interfaces/05-log-parser/01-methods/log_err_negative.txt new file mode 100644 index 0000000..feccc0c --- /dev/null +++ b/interfaces/05-log-parser/01-methods/log_err_negative.txt @@ -0,0 +1,16 @@ +learngoprogramming.com 10 +learngoprogramming.com 15 +learngoprogramming.com 10 +learngoprogramming.com 20 +learngoprogramming.com 5 +golang.org 40 +golang.org 20 +golang.org -50 +golang.org 15 +blog.golang.org 60 +blog.golang.org 30 +blog.golang.org 20 +blog.golang.org 65 +blog.golang.org 15 +inanc.io 30 +inanc.io 70 \ No newline at end of file diff --git a/interfaces/05-log-parser/01-methods/log_err_str.txt b/interfaces/05-log-parser/01-methods/log_err_str.txt new file mode 100644 index 0000000..59a1fd8 --- /dev/null +++ b/interfaces/05-log-parser/01-methods/log_err_str.txt @@ -0,0 +1,16 @@ +learngoprogramming.com 10 +learngoprogramming.com 15 +learngoprogramming.com 10 +learngoprogramming.com 20 +learngoprogramming.com 5 +golang.org FORTY +golang.org 20 +golang.org 45 +golang.org 15 +blog.golang.org 60 +blog.golang.org 30 +blog.golang.org 20 +blog.golang.org 65 +blog.golang.org 15 +inanc.io 30 +inanc.io 70 \ No newline at end of file diff --git a/interfaces/05-log-parser/01-methods/main.go b/interfaces/05-log-parser/01-methods/main.go new file mode 100644 index 0000000..9e6c0ce --- /dev/null +++ b/interfaces/05-log-parser/01-methods/main.go @@ -0,0 +1,39 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import ( + "bufio" + "fmt" + "os" +) + +func main() { + p := newParser() + + fmt.Printf("%T\n", (*parser).parse) + return + + in := bufio.NewScanner(os.Stdin) + for in.Scan() { + parsed := p.parse(in.Text()) + p.update(parsed) + } + + p.summarize() + dumpErrs([]error{in.Err(), p.err()}) +} + +// dumpErrs together to simplify multiple error handling +func dumpErrs(errs []error) { + for _, err := range errs { + if err != nil { + fmt.Println("> Err:", err) + } + } +} diff --git a/interfaces/05-log-parser/01-methods/parser.go b/interfaces/05-log-parser/01-methods/parser.go new file mode 100644 index 0000000..fb76c07 --- /dev/null +++ b/interfaces/05-log-parser/01-methods/parser.go @@ -0,0 +1,100 @@ +// For more tutorials: https://blog.learngoprogramming.com +// +// Copyright © 2018 Inanc Gumus +// Learn Go Programming Course +// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ +// + +package main + +import ( + "fmt" + "sort" + "strconv" + "strings" +) + +// result stores details about a log line +type result struct { + domain string + visits int + // add more metrics when needed +} + +// parser keep tracks of the parsing +type parser struct { + sum map[string]result // metrics per domain + domains []string // unique domain names + total int // total visits for all domains + lines int // number of parsed lines (for the error messages) + lerr error // the last error occurred +} + +// newParser creates and returns a new parser +func newParser() *parser { + return &parser{sum: make(map[string]result)} +} + +// parse result from a log line +func (p *parser) parse(line string) (r result) { + if p.lerr != nil { + return + } + + p.lines++ + + fields := strings.Fields(line) + if len(fields) != 2 { + p.lerr = fmt.Errorf("wrong input: %v (line #%d)", fields, p.lines) + return + } + + var err error + + r.domain = fields[0] + r.visits, err = strconv.Atoi(fields[1]) + + if r.visits < 0 || err != nil { + p.lerr = fmt.Errorf("wrong input: %q (line #%d)", fields[1], p.lines) + } + return +} + +// update the parsing results +func (p *parser) update(r result) { + if p.lerr != nil { + return + } + + // collect unique domains for easy access to sum map + if _, ok := p.sum[r.domain]; !ok { + p.domains = append(p.domains, r.domain) + } + + // keep track of total visits + p.total += r.visits + + // group the log lines by domain + p.sum[r.domain] = result{ + domain: r.domain, + visits: r.visits + p.sum[r.domain].visits, + } +} + +// summarize the parsing results +func (p *parser) summarize() { + sort.Strings(p.domains) + + fmt.Printf("%-30s %10s\n", "DOMAIN", "VISITS") + fmt.Println(strings.Repeat("-", 45)) + + for _, domain := range p.domains { + fmt.Printf("%-30s %10d\n", domain, p.sum[domain].visits) + } + fmt.Printf("\n%-30s %10d\n", "TOTAL", p.total) +} + +// err returns the last error encountered +func (p *parser) err() error { + return p.lerr +} diff --git a/interfaces/functional/Makefile b/interfaces/05-log-parser/functional/Makefile similarity index 100% rename from interfaces/functional/Makefile rename to interfaces/05-log-parser/functional/Makefile diff --git a/interfaces/functional/chartwriter.go b/interfaces/05-log-parser/functional/chartwriter.go similarity index 100% rename from interfaces/functional/chartwriter.go rename to interfaces/05-log-parser/functional/chartwriter.go diff --git a/interfaces/functional/field.go b/interfaces/05-log-parser/functional/field.go similarity index 100% rename from interfaces/functional/field.go rename to interfaces/05-log-parser/functional/field.go diff --git a/interfaces/functional/filters.go b/interfaces/05-log-parser/functional/filters.go similarity index 100% rename from interfaces/functional/filters.go rename to interfaces/05-log-parser/functional/filters.go diff --git a/interfaces/functional/groupers.go b/interfaces/05-log-parser/functional/groupers.go similarity index 100% rename from interfaces/functional/groupers.go rename to interfaces/05-log-parser/functional/groupers.go diff --git a/interfaces/functional/main.go b/interfaces/05-log-parser/functional/main.go similarity index 100% rename from interfaces/functional/main.go rename to interfaces/05-log-parser/functional/main.go diff --git a/interfaces/functional/pipeline.go b/interfaces/05-log-parser/functional/pipeline.go similarity index 100% rename from interfaces/functional/pipeline.go rename to interfaces/05-log-parser/functional/pipeline.go diff --git a/interfaces/functional/result.go b/interfaces/05-log-parser/functional/result.go similarity index 100% rename from interfaces/functional/result.go rename to interfaces/05-log-parser/functional/result.go diff --git a/interfaces/functional/textreader.go b/interfaces/05-log-parser/functional/textreader.go similarity index 100% rename from interfaces/functional/textreader.go rename to interfaces/05-log-parser/functional/textreader.go diff --git a/interfaces/functional/textwriter.go b/interfaces/05-log-parser/functional/textwriter.go similarity index 100% rename from interfaces/functional/textwriter.go rename to interfaces/05-log-parser/functional/textwriter.go diff --git a/interfaces/logs/Makefile b/interfaces/05-log-parser/logs/Makefile similarity index 100% rename from interfaces/logs/Makefile rename to interfaces/05-log-parser/logs/Makefile diff --git a/interfaces/logs/log.json b/interfaces/05-log-parser/logs/log.json similarity index 100% rename from interfaces/logs/log.json rename to interfaces/05-log-parser/logs/log.json diff --git a/interfaces/logs/log.txt b/interfaces/05-log-parser/logs/log.txt similarity index 100% rename from interfaces/logs/log.txt rename to interfaces/05-log-parser/logs/log.txt diff --git a/interfaces/logs/log_err_missing.txt b/interfaces/05-log-parser/logs/log_err_missing.txt similarity index 100% rename from interfaces/logs/log_err_missing.txt rename to interfaces/05-log-parser/logs/log_err_missing.txt diff --git a/interfaces/logs/log_err_negative.txt b/interfaces/05-log-parser/logs/log_err_negative.txt similarity index 100% rename from interfaces/logs/log_err_negative.txt rename to interfaces/05-log-parser/logs/log_err_negative.txt diff --git a/interfaces/logs/log_err_str.txt b/interfaces/05-log-parser/logs/log_err_str.txt similarity index 100% rename from interfaces/logs/log_err_str.txt rename to interfaces/05-log-parser/logs/log_err_str.txt diff --git a/interfaces/oop/final/Makefile b/interfaces/05-log-parser/oop/Makefile similarity index 100% rename from interfaces/oop/final/Makefile rename to interfaces/05-log-parser/oop/Makefile diff --git a/interfaces/oop/final/analysis.go b/interfaces/05-log-parser/oop/analysis.go similarity index 100% rename from interfaces/oop/final/analysis.go rename to interfaces/05-log-parser/oop/analysis.go diff --git a/interfaces/oop/final/chartsummary.go b/interfaces/05-log-parser/oop/chartsummary.go similarity index 100% rename from interfaces/oop/final/chartsummary.go rename to interfaces/05-log-parser/oop/chartsummary.go diff --git a/interfaces/oop/final/filters.go b/interfaces/05-log-parser/oop/filters.go similarity index 100% rename from interfaces/oop/final/filters.go rename to interfaces/05-log-parser/oop/filters.go diff --git a/interfaces/oop/final/groupers.go b/interfaces/05-log-parser/oop/groupers.go similarity index 100% rename from interfaces/oop/final/groupers.go rename to interfaces/05-log-parser/oop/groupers.go diff --git a/interfaces/oop/final/jsonparser.go b/interfaces/05-log-parser/oop/jsonparser.go similarity index 100% rename from interfaces/oop/final/jsonparser.go rename to interfaces/05-log-parser/oop/jsonparser.go diff --git a/interfaces/oop/final/main.go b/interfaces/05-log-parser/oop/main.go similarity index 100% rename from interfaces/oop/final/main.go rename to interfaces/05-log-parser/oop/main.go diff --git a/interfaces/oop/final/readclose.go b/interfaces/05-log-parser/oop/readclose.go similarity index 100% rename from interfaces/oop/final/readclose.go rename to interfaces/05-log-parser/oop/readclose.go diff --git a/interfaces/oop/final/report.go b/interfaces/05-log-parser/oop/report.go similarity index 100% rename from interfaces/oop/final/report.go rename to interfaces/05-log-parser/oop/report.go diff --git a/interfaces/oop/final/result.go b/interfaces/05-log-parser/oop/result.go similarity index 100% rename from interfaces/oop/final/result.go rename to interfaces/05-log-parser/oop/result.go diff --git a/interfaces/oop/final/textparser.go b/interfaces/05-log-parser/oop/textparser.go similarity index 100% rename from interfaces/oop/final/textparser.go rename to interfaces/05-log-parser/oop/textparser.go diff --git a/interfaces/oop/final/textsummary.go b/interfaces/05-log-parser/oop/textsummary.go similarity index 100% rename from interfaces/oop/final/textsummary.go rename to interfaces/05-log-parser/oop/textsummary.go diff --git a/interfaces/refactor-notes/refactor-00/changes.md b/interfaces/05-log-parser/refactor-notes/refactor-00/changes.md similarity index 100% rename from interfaces/refactor-notes/refactor-00/changes.md rename to interfaces/05-log-parser/refactor-notes/refactor-00/changes.md diff --git a/interfaces/refactor-notes/refactor-00/main.go b/interfaces/05-log-parser/refactor-notes/refactor-00/main.go similarity index 100% rename from interfaces/refactor-notes/refactor-00/main.go rename to interfaces/05-log-parser/refactor-notes/refactor-00/main.go diff --git a/interfaces/refactor-notes/refactor-00/parser.go b/interfaces/05-log-parser/refactor-notes/refactor-00/parser.go similarity index 100% rename from interfaces/refactor-notes/refactor-00/parser.go rename to interfaces/05-log-parser/refactor-notes/refactor-00/parser.go diff --git a/interfaces/refactor-notes/refactor-00/result.go b/interfaces/05-log-parser/refactor-notes/refactor-00/result.go similarity index 100% rename from interfaces/refactor-notes/refactor-00/result.go rename to interfaces/05-log-parser/refactor-notes/refactor-00/result.go diff --git a/interfaces/refactor-notes/refactor-00/summarize.go b/interfaces/05-log-parser/refactor-notes/refactor-00/summarize.go similarity index 100% rename from interfaces/refactor-notes/refactor-00/summarize.go rename to interfaces/05-log-parser/refactor-notes/refactor-00/summarize.go diff --git a/interfaces/refactor-notes/refactor-01/changes.md b/interfaces/05-log-parser/refactor-notes/refactor-01/changes.md similarity index 100% rename from interfaces/refactor-notes/refactor-01/changes.md rename to interfaces/05-log-parser/refactor-notes/refactor-01/changes.md diff --git a/interfaces/refactor-notes/refactor-01/main.go b/interfaces/05-log-parser/refactor-notes/refactor-01/main.go similarity index 100% rename from interfaces/refactor-notes/refactor-01/main.go rename to interfaces/05-log-parser/refactor-notes/refactor-01/main.go diff --git a/interfaces/refactor-notes/refactor-01/parser.go b/interfaces/05-log-parser/refactor-notes/refactor-01/parser.go similarity index 100% rename from interfaces/refactor-notes/refactor-01/parser.go rename to interfaces/05-log-parser/refactor-notes/refactor-01/parser.go diff --git a/interfaces/refactor-notes/refactor-01/result.go b/interfaces/05-log-parser/refactor-notes/refactor-01/result.go similarity index 100% rename from interfaces/refactor-notes/refactor-01/result.go rename to interfaces/05-log-parser/refactor-notes/refactor-01/result.go diff --git a/interfaces/refactor-notes/refactor-01/summarize.go b/interfaces/05-log-parser/refactor-notes/refactor-01/summarize.go similarity index 100% rename from interfaces/refactor-notes/refactor-01/summarize.go rename to interfaces/05-log-parser/refactor-notes/refactor-01/summarize.go diff --git a/interfaces/refactor-notes/refactor-02/changes.md b/interfaces/05-log-parser/refactor-notes/refactor-02/changes.md similarity index 100% rename from interfaces/refactor-notes/refactor-02/changes.md rename to interfaces/05-log-parser/refactor-notes/refactor-02/changes.md diff --git a/interfaces/refactor-notes/refactor-02/main.go b/interfaces/05-log-parser/refactor-notes/refactor-02/main.go similarity index 100% rename from interfaces/refactor-notes/refactor-02/main.go rename to interfaces/05-log-parser/refactor-notes/refactor-02/main.go diff --git a/interfaces/refactor-notes/refactor-02/parser.go b/interfaces/05-log-parser/refactor-notes/refactor-02/parser.go similarity index 100% rename from interfaces/refactor-notes/refactor-02/parser.go rename to interfaces/05-log-parser/refactor-notes/refactor-02/parser.go diff --git a/interfaces/refactor-notes/refactor-02/result.go b/interfaces/05-log-parser/refactor-notes/refactor-02/result.go similarity index 100% rename from interfaces/refactor-notes/refactor-02/result.go rename to interfaces/05-log-parser/refactor-notes/refactor-02/result.go diff --git a/interfaces/refactor-notes/refactor-02/summarize.go b/interfaces/05-log-parser/refactor-notes/refactor-02/summarize.go similarity index 100% rename from interfaces/refactor-notes/refactor-02/summarize.go rename to interfaces/05-log-parser/refactor-notes/refactor-02/summarize.go diff --git a/interfaces/refactor-notes/refactor-03-deprecated/changes.md b/interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/changes.md similarity index 100% rename from interfaces/refactor-notes/refactor-03-deprecated/changes.md rename to interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/changes.md diff --git a/interfaces/refactor-notes/refactor-03-deprecated/main.go b/interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/main.go similarity index 100% rename from interfaces/refactor-notes/refactor-03-deprecated/main.go rename to interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/main.go diff --git a/interfaces/refactor-notes/refactor-03-deprecated/parser.go b/interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/parser.go similarity index 100% rename from interfaces/refactor-notes/refactor-03-deprecated/parser.go rename to interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/parser.go diff --git a/interfaces/refactor-notes/refactor-03-deprecated/result.go b/interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/result.go similarity index 100% rename from interfaces/refactor-notes/refactor-03-deprecated/result.go rename to interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/result.go diff --git a/interfaces/refactor-notes/refactor-03-deprecated/scanner.go b/interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/scanner.go similarity index 100% rename from interfaces/refactor-notes/refactor-03-deprecated/scanner.go rename to interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/scanner.go diff --git a/interfaces/refactor-notes/refactor-03-deprecated/summarize.go b/interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/summarize.go similarity index 100% rename from interfaces/refactor-notes/refactor-03-deprecated/summarize.go rename to interfaces/05-log-parser/refactor-notes/refactor-03-deprecated/summarize.go diff --git a/interfaces/refactor-notes/refactor-03/changes.md b/interfaces/05-log-parser/refactor-notes/refactor-03/changes.md similarity index 100% rename from interfaces/refactor-notes/refactor-03/changes.md rename to interfaces/05-log-parser/refactor-notes/refactor-03/changes.md diff --git a/interfaces/refactor-notes/refactor-03/main.go b/interfaces/05-log-parser/refactor-notes/refactor-03/main.go similarity index 100% rename from interfaces/refactor-notes/refactor-03/main.go rename to interfaces/05-log-parser/refactor-notes/refactor-03/main.go diff --git a/interfaces/refactor-notes/refactor-03/parser.go b/interfaces/05-log-parser/refactor-notes/refactor-03/parser.go similarity index 100% rename from interfaces/refactor-notes/refactor-03/parser.go rename to interfaces/05-log-parser/refactor-notes/refactor-03/parser.go diff --git a/interfaces/refactor-notes/refactor-03/result.go b/interfaces/05-log-parser/refactor-notes/refactor-03/result.go similarity index 100% rename from interfaces/refactor-notes/refactor-03/result.go rename to interfaces/05-log-parser/refactor-notes/refactor-03/result.go diff --git a/interfaces/refactor-notes/refactor-03/summarize.go b/interfaces/05-log-parser/refactor-notes/refactor-03/summarize.go similarity index 100% rename from interfaces/refactor-notes/refactor-03/summarize.go rename to interfaces/05-log-parser/refactor-notes/refactor-03/summarize.go diff --git a/interfaces/logparser-testing/log.txt b/interfaces/05-log-parser/testing/log.txt similarity index 100% rename from interfaces/logparser-testing/log.txt rename to interfaces/05-log-parser/testing/log.txt diff --git a/interfaces/logparser-testing/log_err_missing.txt b/interfaces/05-log-parser/testing/log_err_missing.txt similarity index 100% rename from interfaces/logparser-testing/log_err_missing.txt rename to interfaces/05-log-parser/testing/log_err_missing.txt diff --git a/interfaces/logparser-testing/log_err_negative.txt b/interfaces/05-log-parser/testing/log_err_negative.txt similarity index 100% rename from interfaces/logparser-testing/log_err_negative.txt rename to interfaces/05-log-parser/testing/log_err_negative.txt diff --git a/interfaces/logparser-testing/log_err_str.txt b/interfaces/05-log-parser/testing/log_err_str.txt similarity index 100% rename from interfaces/logparser-testing/log_err_str.txt rename to interfaces/05-log-parser/testing/log_err_str.txt diff --git a/interfaces/logparser-testing/main.go b/interfaces/05-log-parser/testing/main.go similarity index 84% rename from interfaces/logparser-testing/main.go rename to interfaces/05-log-parser/testing/main.go index a2372c6..0f5cc83 100644 --- a/interfaces/logparser-testing/main.go +++ b/interfaces/05-log-parser/testing/main.go @@ -11,7 +11,7 @@ import ( "bufio" "os" - "github.com/inancgumus/learngo/27-interfaces/logparser-testing/report" + "github.com/inancgumus/learngo/interfaces/04-log-parser/testing/report" ) func main() { diff --git a/interfaces/logparser-testing/main_test.go b/interfaces/05-log-parser/testing/main_test.go similarity index 100% rename from interfaces/logparser-testing/main_test.go rename to interfaces/05-log-parser/testing/main_test.go diff --git a/interfaces/logparser-testing/report/parser.go b/interfaces/05-log-parser/testing/report/parser.go similarity index 100% rename from interfaces/logparser-testing/report/parser.go rename to interfaces/05-log-parser/testing/report/parser.go diff --git a/interfaces/logparser-testing/report/parser_test.go b/interfaces/05-log-parser/testing/report/parser_test.go similarity index 100% rename from interfaces/logparser-testing/report/parser_test.go rename to interfaces/05-log-parser/testing/report/parser_test.go diff --git a/interfaces/logparser-testing/report/result.go b/interfaces/05-log-parser/testing/report/result.go similarity index 100% rename from interfaces/logparser-testing/report/result.go rename to interfaces/05-log-parser/testing/report/result.go diff --git a/interfaces/logparser-testing/report/summary.go b/interfaces/05-log-parser/testing/report/summary.go similarity index 100% rename from interfaces/logparser-testing/report/summary.go rename to interfaces/05-log-parser/testing/report/summary.go diff --git a/interfaces/logparser-testing/report/summary_test.go b/interfaces/05-log-parser/testing/report/summary_test.go similarity index 100% rename from interfaces/logparser-testing/report/summary_test.go rename to interfaces/05-log-parser/testing/report/summary_test.go diff --git a/interfaces/logparser-testing/summarize.go b/interfaces/05-log-parser/testing/summarize.go similarity index 95% rename from interfaces/logparser-testing/summarize.go rename to interfaces/05-log-parser/testing/summarize.go index 1573f4c..a6f5b4c 100644 --- a/interfaces/logparser-testing/summarize.go +++ b/interfaces/05-log-parser/testing/summarize.go @@ -13,7 +13,7 @@ import ( "os" "strings" - "github.com/inancgumus/learngo/27-interfaces/logparser-testing/report" + "github.com/inancgumus/learngo/interfaces/04-log-parser/testing/report" ) // summarize prints the parsing results.