package main
var PQ pqueue.PQueue
var firstNode pqueue.Node
PQ.Push(firstNode)
The variable firstNode
is passed by value which means that there is an implicit assignment of the argument to the parameter in the function call PQ.Push(firstNode)
. The type pqueue.Node
contains private fields such as row
which are not exported from package pqueue
to package main
: "implicit assignment of unexported field 'row' of pqueue.Node in function argument."
In Node.go
, add this function to package pqueue
:
func NewNode() *Node {
return &Node{}
}
In PQueue.go
, add this function to package pqueue
:
func NewPQueue() *PQueue {
return &PQueue{}
}
Then. in package main
, you can write:
PQ := pqueue.NewPQueue()
firstNode := pqueue.NewNode()
PQ.Push(firstNode)