Here is the Go code I was working with, a nice example of concurrent computing ...

// sieve.go
// a concurrent prime sieve
// the prime sieve: Daisy-chain Filter processes

package main

import "fmt"

// send the sequence 2, 3, 4, ... to channel 'ch'
func Generate(ch chan<- int) {
    for i := 2; ; i++ {
        // send 'i' to channel 'ch'
        ch <- i
    }
}

// copy the values from channel 'in' to channel 'out',
// removing those divisible by 'prime'.
func Filter(in <-chan int, out chan<- int, prime int) {
    for {
        // receive value from channel 'in'
        i := <-in
        if i%prime != 0 {
            // send value 'i' to channel 'out'
            out <- i
        }
    }
}

func main() {
    // create a new channel
    ch := make(chan int)
    // launch Generate goroutine
    go Generate(ch)
    // get the first 10 primes
    for i := 0; i < 10; i++ {
        prime := <-ch
        fmt.Println(prime)
        ch1 := make(chan int)
        go Filter(ch, ch1, prime)
        ch = ch1
    }
}

/*
2
3
5
7
11
13
17
19
23
29
*/

The for loop is the only loop in Go but it covers all the possible loops.

Comparing C/C++ and Go types:
+--------------------+------------------+
| C/C++ type         | Go type          |
+--------------------+------------------+
| bool               | bool             |
| char               | byte             |
| signed char        | int8             |
| unsigned char      | byte             |
| short              | int16            |
| unsigned short     | uint16           |
| int                | int              |
| unsigned int       | uint             |
| long               | int32 or int64   |
| unsigned long      | uint32 or uint64 |
| long long          | int64            |
| unsigned long long | uint64           |
| float              | float32          |
| double             | float64          |
| char * or char []  | string           |
+--------------------+------------------+

Still no GUI toolkit for Go.

@iamthwee,
you not only got me hooked on Go, but also Shoes!
Darn you anyway! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.