Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

python's list type implementation on go.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 list.go
Octocat-spinner-32 list_test.go
README.md

golist Build Status Clone in Koding

python's list type implementation on go.

installation

$ go get github.com/emre/golist

Initialization of a new List

my_list := golist.New()
my_list := golist.New("Galatasaray", "Real Madrid")

Appending items

my_list.Append("Drogba")
my_list.Append("Bruma")

Extending list with another list

other_list := golist.New("Ronaldo", "Bale")
my_list.Extend(other_list)

Get an index for the element

index, err := my_list.Index("Drogba")
if err != nil {
    fmt.Println(err)
}
fmt.Println(index)

Counting items

my_list.Append("Drogba", "Drogba")
drogba_count := my_list.Count("Drogba")
fmt.Println(drogba_count)

Deleting items by value/index

// by value
my_list.Remove("Drogba")

// by index
my_list.Delete(0)

Pop items

// pops the item which of index zero.
value, err := my_list.Pop(0)

// pops latest item
value, err := my_list.Pop()

Reversing a List

goals_list := golist.New("18:Drogba", "56:Bale", "90+2:Sabri Sarioglu")
goals_list.Reverse()

Get the size of list

list_size := goals_list.Len()

Further documentation

Bitdeli Badge

Something went wrong with that request. Please try again.