Hi,

I would like to import go files local. But I got the following error
when I try use `add()`. Does anybody know how to fix the error?
Thanks.

$ cat.sh mypackage/myfile.go main.go
==> mypackage/myfile.go <==
package mypackage

import "fmt"

type Export struct {
}

func (c Export) DoMagic() {
  fmt.Println("Magic function was called")
}

func (c Export) String() string {
  return fmt.Sprint("ta da! \n")
}

func add(x, y int) int {
  return x + y
}

==> main.go <==
package main

import (
  "fmt"
  "./mypackage"
)

func main() {
  var value mypackage.Export
  value.DoMagic()
  fmt.Printf("%s", value)
  fmt.Print(mypackage.add(1, 2))
}
$ go build main.go
# command-line-arguments
./main.go:12:13: cannot refer to unexported name mypackage.add
./main.go:12:13: undefined: mypackage.add


-- 
Regards,
Peng

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to