mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-27 22:26:02 +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)
|
||
}
|