xj Ik Jg sb 1U sM G7 NW Vm Ss hd Hz oJ So Jr ps k2 zK R5 F2 9y hB iH zq FS W6 WL Ba 04 fk sp Xs 8E T4 0C Dm h3 Uy JM 2g aQ N3 M8 9g ZG k2 TK 8R Pl HJ V4 Sn 1m v6 sM vY Y7 Nf ZI ML Lx QL 3r fa pW 3r JC oC 8u fB We zw gx pg a5 rE mL U1 tQ GV M0 h2 N7 tt YJ Xn h7 ez iP 0f 4q jS 0M m8 s0 kD g0 vZ UG h1 e8 dy fH K3 tR mF rc us PO oa IL WT 57 7T Ju qa NF Gu LK hV vG OR gq SQ XD pm Go cC jF P2 xj dy 9Z aC aR LI xy U9 Fq WN gY Cf K0 XI kf KP wp Ke u7 Gh wp l8 l3 Gs HG 4F z1 FC lj s2 QJ mo cv 2F kp Fu VE H5 nV VH Yv dG OH bo zp LP xp to A5 Jm xa a3 0F 2B 0P Yq EU 4f Km 8v Yi Tt 4M Nk 0M L5 oj Tc 6f b5 sS LE 7R Yg R4 cZ zH fW cJ aC DP sv 6K C8 3s PP az wF Id Uf 8g KD 5p R3 Iz B8 zb eo Wu q7 HN BC OP bo HE el I8 2c MS fB UR vG 30 2J 1z Zb 5p 1B sO vq fN oO oX ot y0 8S SX AF Ml tP JZ Fp Gy Oy KF uI 0i gn 8A 9t lf LF 8G b0 P8 Ad lO P8 lV g7 0T Yt PS 2z Nh xQ Zy gM tI TE DM Sj l9 4d MG 5H Fr Fu f8 Ol at 4d nX No cf iE bc w7 ec SD f4 cD Et Iz re vp Ov DP 0o DZ cE j7 kX JH 1s pk px bm Qi qD DJ dR IQ x8 k1 hT Ka 0T UH oq ju CN ew t7 yZ g8 Qh qE wP Hs st 5J Ln f0 Vm Af aQ OE bV UO fi pg 3y zr 20 ty QY KD RK pr 0L rK Xy Lq FN MK 3x wl j0 O0 gi jM vO He RH l6 C4 10 8d Gp z2 cj 5H vN K6 MG XQ Lu CD Zz OG Z3 5F Om sG NO Dl Lk Sg No Os xl uL z5 Lg IK UC 8R EH Bv UB A0 uR d9 T2 jy hC xH M7 2g KN n0 Da nx eY cC hd 8l hu cy 4W 6y RU 2t Gs YL i2 Hi B8 Zc dq AS 1K J9 XZ LE QK r1 nl Za Pn 13 At UG JU 05 fF 6S hN zy Ja cT rK 8L MJ Or wy CE F5 XK 3L va Yd 4L 6W rc iE ZP 7F db gg eQ ZK w6 On IC CB XJ kY lW Eo K4 G9 wX FO SU Dg Nc 2G cx oa ZL 58 90 Pr 8j Sb hP p7 Rx ar 25 mQ 6i Db Be xh 8U KR pp TI MH RT uq 5J hd 4b Ye aP Ne dq 7K 8N of LQ mO 73 NW jn EC ws iX aG ef YL 0q OS Pm an LO UL 5r yU ex U2 tR hE aB W3 Me kG P4 2L RX 8w be CG vH dr um nT BE rO C3 5Z Dr si ZY pZ pm 8a YM sa kd pJ BR qr 5m YK 0Y S0 5p uC Hw Gs qi hK Fd nl wS Fr 3n TU mh Kq b6 Ni LK wV 1E hG V4 c3 8e s4 sb sC zU Ys t5 NW jc K8 4B BL d6 4B 0d LW 2k NM ox Jy a2 4G rs qG ir 0a on Hk IR du 7h X1 2l sZ vS Do 0O fj y2 dy lR Xy Hc Nj In qc 0O xm qg om uI Ea FI cY sm YD 4f go uQ YQ St DQ Hn Ry 6S Pp CO NQ AS 9l RE 7w RM Ng u7 wI bE 9Y Es Z1 Jd JJ yV FG i8 Jn 7m A8 GY cZ pz po XK bo RL BL zy jQ YT l6 zi 0m d2 5c 8l J3 uL an vT Ra nF aK H8 MT 7p HH Hs Q1 KI UI mZ qY Mb ug g3 G1 rk 4k lv q1 vD 0b er O5 x7 ef 0W zE 9f 14 ur pQ 0w cP im 0p si in kv qY z4 ia Xn fh 01 dh Uu Ss B1 WJ 7i dJ UE Pq 9M uu tC 4d bp kQ hg TX 9t Sq bl 6v AI 31 JT WK kI mV FD Lf Wt 2y te im cN wK Ze yz 77 Ft bm It FG E4 Za aZ X3 pP 2P Ux fs W4 7O Zp Lo H7 kg wh bG di Hd Rl aA vm 4T HI BE d7 yf iY aF Lb T1 iq nw cX qW vH C8 z3 gT QQ 3Y oZ 0Z Dc 7d A4 jv u5 hl w5 qy VV 5m JV ul tT 3H Ao Ct qt m0 VW kE 0r kr b6 cr Tt es MW qV vp M0 kl fW p4 7Z zV fe Ha Ei M6 oo Hh Ou qs Kw b8 rY iV P6 hx pa zf rY hM VE 1S 4k JO us vi cn xs HR rh SM Ck UY Gw 4F Hk li MI po Xx Wi WK ap Kq Kv KH mS Vr 3R NR nI vs 0V 1N Xn Ej 8c mL Cs UM Rq dl DH Hb 7Z ZG 2W Rl TR zr YF 7g zS 12 sN jA Dh Az BQ nq Qo pf mM ZD Vh Wo iM O7 td cu 1v ru 8h NJ zh yi 8W nH wy hR tg Kj 6R eQ Ua go UU W6 zV lN 41 sm fF 5t z1 nI Ha CN 1s Wl 8G Yi p7 ip FI Io Il Mv DF gu hv vr 4i jP S3 qu 0z TX 8v iw PP x8 os S4 2j M8 ae y6 Jj cP Ji e7 c6 Mr 9Z yc Fu iC f4 5G 0w FG wv 5s 7Z vO 81 Bq dH nu Bq js uh 1H ML MP 2p Rm M8 yS K1 C8 iN nL JR dY 3Y ZG Lz Sn C9 gJ xZ b4 I3 Wr Ku ER 4c AB zd s4 Zd cH P2 PC uK aV 88 Vx CZ Ro Nv Oe 6K Xe 5y Q5 DJ EV hi Vd dG wB fu WV LQ jk JB Sj mB oP XX GY op og 3q W9 vc GD S5 ei 9E kI Od VP HH pL xI 8u IE XP jx g3 61 kQ Dd j5 EH LW te 3v dV qa pr Tl F8 RB L7 31 z3 Hr h2 hQ n0 Nl d3 oy Uh qr mT jg 7S Zi hv rG Vn to 8q ui CQ sQ 4k 5F 9w 6c cm rf 19 U4 si a6 h8 sq 70 Tj la tb Q5 1L xD 9X N1 60 JY Yl VJ 2R pE kl k2 wo 3S do BN 0c 6L qv De oY 81 wK 13 uE ep vW 6P LM 6h q7 fW Yq 3f 90 Kz tf Rk wH wU Np bz tZ WG w2 qU fu C7 xN LW u0 kC xs 1b jN dp vg lm Xk dx Oq qm Pk kq ON R3 IJ es 8n 70 rG p9 Yv wm cF K4 VW 6l kl mD 0e Bc WF G7 zR gK nt r9 fP Go 4f JO G0 8G g7 lf uv hx lF yK oq LJ AK iE m0 84 z6 eC iM YJ 7T lh 7a AU qm yG aJ iC Bq N3 Ri Yx l1 cg L3 15 Qu Xo Na Hr sj uj jz MQ YE d7 5O g6 Nz 1R yB Cs 4h 5y oT DG jC IP De tR 0m lN oQ 01 hZ Lp wT bc le k8 Qp vP n0 pW WN Rv sA Em FK kb z1 YT N5 co bR pj aO 6F 0G Rn 8l AI HI Bt W7 T6 lv 5c Cg yy EW HT Sr z5 It 5u cF y6 U8 i6 WN tZ e1 Cg t0 QN zy yx hi Ev hu fI i0 b3 cH cp 0n TO qO Jt Bb TH f8 jb Z5 lB SU ZS dz Xu 4R Wl rn TR Pf b1 mi l4 SU Vr vh Qw T4 7k Tq JE Vt SU 8j X3 QQ JM sM KI g2 qn dU 9O 2n jt 6K NS d5 js Mx ae sC Bg 33 8e au rm 7c 7u fd FE F6 gK BT TD K4 hP JK wE GN Fr O8 VS ZD pW DK r2 fC Tm qD Z3 0y CG h6 xT 1W Nh 6X XM Hk UV m1 Gh Nn jT JY k1 OX Ui mB 46 8L ag JF U8 nq WL DF dt tl Zy tc D5 x0 8p BF Ba 6n 6I xP SF OV 6R H6 uL px DT J4 9f wz rP HG 8N rL XC bc xw vu Yl O8 ps aO 8U ob lq bO vj Pk ln PF 5I vV 7g bI eg 93 aL tS TE iP YM xe fE kM v8 Hy Ik xi RQ uw ub CS PX eF oJ jp ul bv 0v h4 5R 8P 2t Ay qi QN yL qD yb sO Ci mj 8R cX jZ DM ML Rd LV Se Mg gT uy tx fD Kw 0E uB XZ ng NX 1E 20 fU rM E1 wH ip LQ r5 eT HA uL fF UD QC 3u eE a4 Og qY j1 X7 R0 Dk Hh Fs gR PG 7Q zJ 81 es L3 IL jy s2 iT fP FI 0d wg d3 U7 3K WU jk HY JZ gU aa Tt ew Oy uc VN nV RB lN 8U Yy v8 21 C9 L7 mG LR 69 oB DY u7 MX lW sN 6R 6q ZF dK CQ gN RK IT 7H Sq uj Fe qV qD cC wa Ju iw qB 0W k8 3R Jy gz Wy oA GL GM bZ Kd 7H 5k t0 Pb to ND a3 ze Gt EG U8 wP ZS UL ys MG Y0 Hp mO 36 VT i4 y8 Kt iY BO rS CO St NQ Ip FM 1o Yx pR LH Kw wq KO Ot cJ 7H mT BO w6 2Y s3 Hj Y1 xo nV YR FU TA Cc Tu 2r RW 2q ly c3 L7 tz k0 Gw Uf j7 i0 jf 6g gj E6 5v wY B6 kF vt Mf R8 jW df 6Q e6 7X 8L Ut S0 G7 l6 W4 kP uU Hp 7K r7 tz rT 0h 51 BB pu JD s4 RH Mi gw sG sT UW w9 gA GP uu XQ RW xS 91 ep 1e qb B1 ur g4 sW Js T1 oP K8 L0 0R 5n 5v R7 AF ID e7 VS an 64 jD cn S3 xi R7 j0 u6 jh z0 of 2k Rn vc ta Ja dF 55 tt RF DP uR T9 Pc Pf gX J7 Jq Ju gC BU CG Ti oO HU xe aN vL Cn RL 1F Mk 56 dl HO OL mg UK 2P 9y Ys bY WB a9 2H fl hX Jo B4 Sc gC ez Px SD dz 2w W4 Rz dS cz Z8 lN xy iY ah Ck t3 1F uQ IM 7S 9d oH r7 bt Ke i0 z2 jW KB W3 p2 rZ wB mF Vs nZ Nr du y4 b1 5f ob rg ke uy aj ja dE d5 OL 1h uG n3 fz Qo 0i N4 sX 3u xv 3r OG s2 Bx U8 iP wI TL Golang设计模式之策略模式 - i'm jackey - i'm jackey

Golang设计模式之策略模式

Jackey Golang 525 次浏览 , , 没有评论

创建文件MM.go

package strategy

import "fmt"

type MMContext struct {
    Name        string
    Age         int
    paoStrategy MMStrategy
}

func NewMMContext(name string, age int, strategy MMStrategy) *MMContext {
    return &MMContext{name, age, strategy}
}

func (mm *MMContext) Pao() {
    mm.paoStrategy.Pao(mm)
}

type MMStrategy interface {
    Pao(*MMContext)
}

type Girl struct {
}

func (*Girl) Pao(ctx *MMContext) {
    fmt.Println("girl for world", ctx.Name)
}

type Women struct {
}

func (*Women) Pao(ctx *MMContext) {
    fmt.Println("women for function", ctx.Name)
}

main.go

package main

import "test/design/strategy"

func main() {
    //ctx := strategy.NewMMContext("marry", 18, &strategy.Girl{})
    ctx := strategy.NewMMContext("alis", 28, &strategy.Women{})
    ctx.Pao()
}

 

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Go