Merge pull request #20 from ldez/feature/go

feat: add go version
This commit is contained in:
Emily Bache 2015-10-21 21:09:47 +02:00
commit 2235211d6f
3 changed files with 103 additions and 0 deletions

7
go/gilded-rose_test.go Normal file
View File

@ -0,0 +1,7 @@
package main
import "testing"
func Test_GildedRose(t *testing.T) {
main()
}

75
go/glided-rose.go Normal file
View File

@ -0,0 +1,75 @@
package main
import "fmt"
type Item struct {
name string
sellIn, quality int
}
var items = []Item{
Item{"+5 Dexterity Vest", 10, 20},
Item{"Aged Brie", 2, 0},
Item{"Elixir of the Mongoose", 5, 7},
Item{"Sulfuras, Hand of Ragnaros", 0, 80},
Item{"Backstage passes to a TAFKAL80ETC concert", 15, 20},
Item{"Conjured Mana Cake", 3, 6},
}
func main() {
fmt.Println("OMGHAI!")
// fmt.Print(items)
GlidedRose()
}
func GlidedRose() {
for i := 0; i < len(items); i++ {
if items[i].name != "Aged Brie" && items[i].name != "Backstage passes to a TAFKAL80ETC concert" {
if items[i].quality > 0 {
if items[i].name != "Sulfuras, Hand of Ragnaros" {
items[i].quality = items[i].quality - 1
}
}
} else {
if items[i].quality < 50 {
items[i].quality = items[i].quality + 1
if items[i].name == "Backstage passes to a TAFKAL80ETC concert" {
if items[i].sellIn < 11 {
if items[i].quality < 50 {
items[i].quality = items[i].quality + 1
}
}
if items[i].sellIn < 6 {
if items[i].quality < 50 {
items[i].quality = items[i].quality + 1
}
}
}
}
}
if items[i].name != "Sulfuras, Hand of Ragnaros" {
items[i].sellIn = items[i].sellIn - 1
}
if items[i].sellIn < 0 {
if items[i].name != "Aged Brie" {
if items[i].name != "Backstage passes to a TAFKAL80ETC concert" {
if items[i].quality > 0 {
if items[i].name != "Sulfuras, Hand of Ragnaros" {
items[i].quality = items[i].quality - 1
}
}
} else {
items[i].quality = items[i].quality - items[i].quality
}
} else {
if items[i].quality < 50 {
items[i].quality = items[i].quality + 1
}
}
}
}
}

21
go/readme.md Normal file
View File

@ -0,0 +1,21 @@
# GO Starter
- Run :
```shell
go run gilded-rose.go
```
- Run tests :
```shell
go test
```
- Run tests and coverage :
```shell
go test -coverprofile=coverage.out
go tool cover -html=coverage.out
```