mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-22 11:56:03 +03:00
32 lines
436 B
Go
32 lines
436 B
Go
package objectpool
|
||
|
||
import (
|
||
"fmt"
|
||
"strconv"
|
||
)
|
||
|
||
type doctor struct {
|
||
name string
|
||
kind int //科室,1内科,2外科
|
||
}
|
||
|
||
type pool chan *doctor
|
||
|
||
func newPool(total int) pool {
|
||
p := make(pool, total)
|
||
|
||
for i := 0; i < total; i++ {
|
||
|
||
dc := new(doctor)
|
||
dc.name = "doctor: " + strconv.Itoa(i)
|
||
p <- dc
|
||
}
|
||
|
||
return p
|
||
}
|
||
|
||
//surgery
|
||
func (d doctor) surgery(someone string) {
|
||
fmt.Println("doctor:", d.name, "do surgery for", someone)
|
||
}
|