Hi Team ,
I am new to golang , I have writter a small script refrencing function and structure in another file . I am able to run the script by default structure initialize
Main script
package main
import (
“fmt”
“local/find”
)
func main() {
d:=find.Sam{}
for i:=0;i<100;i++ {
if find.Odd(i) {
fmt.Println("even number",i)
} else {
fmt.Println("odd number",i)
}
fmt.Println("Finding the number",d.Add(i,2))
}
}
--------package
package find
type Sam struct {
j int
}
func Odd(a int) bool {
if a%2 == 0 {
return true
} else {
return false
}
}
func (d *Sam)Add(a, b int) int {
d.j=a + b + d.j
return d.j
}
I want to initialize j to 100 , right now it getting error if initialize to 10