View ring_buffer.go
type RingBuffer struct {
queue uint64
dequeue uint64
mask, disposed uint64
nodes nodes
}
View defer.go
func findHelloWorld(filename string) error {
file, err := os.Open(filename)
if err != nil {
return err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
if scanner.Text() == "hello, world!" {
View mq_benchmark.go
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/tylertreat/bench"
"github.com/tylertreat/bench/requester"
View benchmark.go
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/gocql/gocql"
"github.com/nats-io/nats"
View wtf.go
func isInt64InSlice(i int64, slice []int64) bool {
for _, j := range slice {
if j == i {
return true
}
}
return false
}
View iterator2.go
type IntContainer []int
func (i IntContainer) Iterator(cancel <-chan struct{}) <-chan int {
ch := make(chan int)
go func() {
for _, val := range i {
select {
case ch <- val:
case <-cancel:
close(ch)
View iterator.go
type IntContainer []int
func (i IntContainer) Iterator() <-chan int {
ch := make(chan int)
go func() {
for _, val := range i {
ch <- val
}
close(ch)
}()
View map_lookup.go
intMap := make(map[string]int)
// Valid
value, ok := intMap["foo"]
println(value, ok)
// Also valid
value := intMap["foo"]
println(value)
View mangos_race.txt
go test -race github.com/gdamore/mangos/test
--- FAIL: TestBusTLS (1.00s)
common_test.go:500: Address tls+tcp://127.0.0.1:43934, 5 Cases
common_test.go:149: Jan 14 19:17:27.210: Id 0: Got dup START from 1
common_test.go:149: Jan 14 19:17:27.382: Id 0: Got dup START from 1
common_test.go:149: Jan 14 19:17:27.382: Id 0: Got dup START from 2
common_test.go:149: Jan 14 19:17:27.473: Id 0: Sent all 7 messages
common_test.go:149: Jan 14 19:17:27.477: Id 4: Got all 7 messages
common_test.go:149: Jan 14 19:17:27.477: Id 3: Got all 7 messages
common_test.go:149: Jan 14 19:17:27.478: Id 2: Got all 7 messages
View mangos_service_discovery.go
survey, _ = surveyor.NewSocket()
survey.AddTransport(tcp.NewTransport())
survey.Listen("tcp://:8000")
survey.SetOption(mangos.OptionSurveyTime, time.Second)
for {
survey.Send("Is anybody out there?")
for {
if msg, err = survey.Recv(); err != nil {
break