What i meant was, i 've created a simple pkg for fifo queue, as below
type node_ struct {
value string
prev *node_
next *node_
}
type FifoString_ struct {
first *node_
last *node_
Count uint64
}
func (o *FifoString_) Push(s string) {
var n *node_
n = new(node_)
if n == nil { return }
n.value = s
if (o.Count == 0) {
o.first = n
o.last = n
} else {
n.prev = o.last
o.last.next = n
o.last = n
}
o.Count++
if n == nil { return }
}
func (o *FifoString_) Pop() (o1 string, o2 bool) {
if o.Count == 0 { return "", false }
o.Count--
s := o.first.value
if o.Count == 0 {
o.first = nil
} else {
o.first = o.first.next
}
return s, true
}
so when i null out the var on Pop() method, im leaving it to GC to
clear it, is there a way to manually clear them?
On May 13, 2:33 pm, Andrew Gerrand <
a...@golang.org> wrote:
> There is no such thing as a "dynamic variable" in Go.
>
> Once you declare a variable, it has a value (its type's zero value,
> unless otherwise specified).
>
> You can, however, structure your code such that variables you're no
> longer using fall out of scope when you're done with them.
>
> In the following trivial example, the second time d is declared it
> actually creates a new variable, which effectively disappears after
> the inner block closes.
>
> If you were to remove the first variable declaration, the program
> wouldn't compile as the second println statement would refer to a d
> that doesn't exist there.
>
> --
>
> package main
>
> func main() {
> d := 1
> {
> d := 2
> println(d)
> }
> println(d)
>
> }
>
> --
>
> Hope this helps!
> Andrew
>