redeclared as imported package name

包的绝对路径的最后一个包名可以重复,但是同时使用两个包含相同后缀包名时必须重命名,否则会出现
>demos redeclared as imported package name

main.go #

package main

import (
	"demo/model"
	d1 "demo/model/demos"  //rename demo/model/demos tpp d1
	d2 "demo/models/demos"

	// "demo/model/demos"
	// "demo/models/demos"
)

func main() {
	// a := demos.A{N: 10}
	// b := demos.A{N: 12}
	// a.Demo()
	// b.Demo()

	a := d1.A{N: 10}
	b := d2.A{N: 10}
	a.Demo()
	b.Demo()
}

/*/demos.go #

package demos

type A struct {
	N int
}

func (this A) Demo() {
	println("in model!!!! a's demo'", this.N)
	//println("in models!!!! a's demo'", this.N)
	// fmt.Printf("model.VariableA: %+v\n", model.VariableA)
}

2015-08-30