I am trying to convert this java to golang and now I have this bug. I don't know why this bug is showing up.
here is the java code:
ArrayList<Cell> path; // path does not repeat first cell
String name;
static int count = 0;
public Path() {
this.path = new ArrayList<>();
this.name = "P" + (++this.count);
}
public Path(Path op) {
this.path = new ArrayList<>();
this.name = op.name;
path.addAll((op.path));
}
Here is what i wrote
type Path struct {
name string
count int
path []Cell
}
func NewPath() (p *Path) {
p = new(Path)
p.path = []Cell{}
p.count = 0
p.name = "P" + strconv.Itoa(1+p.count)
return
}
func NewPath(op Path) (p *Path) {
p = new(Path)
p.path = []Cell{}
p.count = 0
p.name = op.name
p.path = append(p.path, op.path)
return
}
The go system said I am wrong in term of redeclaring NewPath, with the error:
prog.go:21:6: NewPath redeclared in this block
How can I debug it?