Note that there are some explanatory texts on larger screens.

plurals
  1. POGo undefined imported function
    primarykey
    data
    text
    <p>I have a problem using a function when there should not be any problem. In Go, a Function that starts with a capital letter has a visibility outside the package.</p> <hr> <h2>node.go</h2> <pre><code>package grid type Node struct { id uint name string pos_i uint pos_j uint node_type string } </code></pre> <h2>grid.go</h2> <pre><code>package grid /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ the Grid Structure ____________________________________________________________________________ */ type Grid struct { // The numbers of divisions in the Grid number_lines uint number_columns uint // The Sizes of the Grid width uint height uint // An Array of the Nodes nodes []Node } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Initialize the Grid ____________________________________________________________________________ */ func InitGrid() *Grid { g := new(Grid) g.number_lines = 4 g.number_columns = 4 g.width = 400 g.height = 400 return g } </code></pre> <h2>main.go</h2> <pre><code>package main import ( "fmt" "grid" ) /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entry Point of the Application ____________________________________________________________________________ */ func main() { grid_ := grid.InitGrid() fmt.Println(grid_) } </code></pre> <hr> <h2>src/grid/Makefile</h2> <pre><code>include $(GOROOT)/src/Make.inc TARG=grid GOFILES=\ node.go\ grid.go\ include $(GOROOT)/src/Make.pkg </code></pre> <h2>src/main/Makefile</h2> <pre><code>include $(GOROOT)/src/Make.inc TARG=main GOFILES=\ main.go\ include $(GOROOT)/src/Make.cmd </code></pre> <hr> <p>When I compile the grid package, everything goes well, but when I try to compile le main package, it gives me that error message:</p> <pre><code>manbear@manbearpig:~/Bureau/go_code/main$ gomake 6g -o _go_.6 main.go main.go:15: undefined: grid.InitGrid make: *** [_go_.6] Erreur 1 </code></pre> <p>I don't understand why it gives me that error, I've passed some time reading the Go documentation, but I don't find the reason why it doesn't work.</p> <p>Thank you for your help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload