On 2012/03/29 20:55, Sergey Bronnikov wrote:
> On 03:10 Fri 30 Mar , Joel Sing wrote:
> > 
> > Updated port attached which combines this with the corrected PLIST.
> 
> same errors for me:
> 
> ~/tmp/go$ go build pi.go
> # runtime
> /usr/local/go/src/pkg/runtime/extern.go:121: undefined: defaultGoroot
> /usr/local/go/src/pkg/runtime/extern.go:130: undefined: theVersion
> /usr/local/go/src/pkg/runtime/extern.go:135: undefined: theGoos
> /usr/local/go/src/pkg/runtime/extern.go:135: cannot use theGoos as type 
> string in const initializer
> /usr/local/go/src/pkg/runtime/extern.go:139: undefined: theGoarch
> /usr/local/go/src/pkg/runtime/extern.go:139: cannot use theGoarch as type 
> string in const initializer
> ~/tmp/go$ 
> 

Check that you actually built new packages and didn't trip into
PLIST_DB checks and that you actually updated the installed
packages; this works fine for me.

$ cat pi.go
// Concurrent computation of pi.
// See http://goo.gl/ZuTZM.
//
// This demonstrates Go's ability to handle
// large numbers of concurrent processes.
// It is an unreasonable way to calculate pi.
package main

import (
        "fmt"
        "math"
)

func main() {
        fmt.Println(pi(5000))
}

// pi launches n goroutines to compute an
// approximation of pi.
func pi(n int) float64 {
        ch := make(chan float64)
        for k := 0; k <= n; k++ {
                go term(ch, float64(k))
        }
        f := 0.0
        for k := 0; k <= n; k++ {
                f += <-ch
        }
        return f
}

func term(ch chan float64, k float64) {
        ch <- 4 * math.Pow(-1, k) / (2*k + 1)
}

$ go build pi.go  
$ ./pi
3.1417926135957908

Reply via email to