Given that Go does not have classes does anybody have a finished code base for the Gilded Rose Kata?
I’ve taken it to the switch statement but am not sure where to go from there.
I ask because on watching Sandi Metz do this Kata in Ruby she uses classes in the final part of the video - https://youtu.be/8bZh5LMaSmE What extra refactoring is necessary?
The rules for the refactoring kata are at https://kata-log.rocks/gilded-rose-kata and the Go start files are at https://github.com/emilybache/GildedRose-Refactoring-Kata
Thanks
`package main
type Item struct {
name string
sellIn int
quality int
}
func UpdateQuality(items []*Item) {
for i := 0; i < len(items); i++ {
item := items[i]
switch item.name {
case "+5 Dexterity Vest", "Elixir of the Mongoose":
Normal(item)
case "Conjured Mana Cake":
Conjured(item)
case "Aged Brie":
AgedBrie(item)
case "Backstage passes to a TAFKAL80ETC concert":
Backstage(item)
default:
break
}
}
}
func Normal(item *Item) {
if item.sellIn > 0 {
item.quality -= 1
}
if item.sellIn <= 0 {
item.quality -= 2
}
item.sellIn -= 1
}
func Backstage(item *Item) {
if item.sellIn <= 5 && item.quality >= 50 {
item.quality += 3
}
if item.sellIn <= 10 && item.quality >= 50 {
item.quality += 2
}
item.sellIn -= 1
item.quality += 1
if item.sellIn == 0 {
item.quality = 0
}
}
func AgedBrie(item *Item) {
item.sellIn -= 1
item.quality += 1
}
func Conjured(item *Item) {
item.quality -= 2
item.sellIn -= 1
}
`