Exercise 2 completed
This commit is contained in:
21
ex2/logger.go
Normal file
21
ex2/logger.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
type Log struct {
|
||||
Msg string
|
||||
}
|
||||
|
||||
type Logs []Log
|
||||
var LogList Logs
|
||||
|
||||
func (ll *Logs) Log(msg string) {
|
||||
*ll = append(*ll, Log{msg})
|
||||
}
|
||||
|
||||
func (ll Logs) ToString() string {
|
||||
res := ""
|
||||
for _, log := range ll {
|
||||
res += log.Msg + "\n"
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user