mchirico / zDaily

Playground to hack and test ideas with Zoe
1 stars 2 forks source link

Day 46: Do something creative with ... #52

Open mchirico opened 3 years ago

mchirico commented 3 years ago

Do something creative with https://github.com/ZoeChiri/util

package main

import "sync"

type UT struct {
    Function func(string) map[string]string
    Mymap map[string]string
    Name string
    sync.Mutex
}

type LINK struct {
    Head *LINK
    Next *LINK
    UT  *UT
}

func NewUT() *UT{
    ut := &UT{}
    ut.Mymap = map[string]string{}
    ut.Name = "GreyGrayPuff"
    ut.Function = func(s string) map[string]string{
        m:=map[string]string{}
        m[s]="Mouse"
        return m
    }
    return ut
}
func (ut *UT)DoSomething(s string){
    ut.Lock()
    defer ut.Unlock()

    ut.Mymap[s] = "Boseman"

}
func main() {
    ut := NewUT()
    l := &LINK{}
    l.Head = l
    l.UT = ut
}
tacomonkautobot[bot] commented 3 years ago

mchirico, Thanks for opening this issue!

ZoeChiri commented 3 years ago

repo is public https://github.com/ZoeChiri/util

mchirico commented 3 years ago

Cool! Now we can work on refactoring... make it more like a real open source project.

A great book on how to do this is Martin Flower's book. Actually, there's a lot in that sample chapter.

Refactoring2-free-chapter.pdf

image