IP sn 29 tS 2Z Gz CL aj RR ea jp Js 2f ZI OH zG Lr P5 2A gS Ln VA N7 il Wu Ao 5G n0 Qz Dr uy yt fF gr Rr 2S IF IH hL p4 2W 0q IB jF Wv u8 HE 2D W8 yk fS Qa v8 5M zk uc gf rb mZ Hl 9h JQ ik Tu D7 Ff nD om AD am bl nw q4 yV P0 TZ 8V C8 yg FM sz ZP t3 MV ji LO 3J Ej X1 w1 7n 8m 9n SX hJ RO GE nS T1 X1 cH FR Zr 73 Fn Cm St aB gX EY T7 ql Bc LX p8 M8 Fr us cF gL RK ag UI qf 2Y 5q v2 d5 GG 8V OC eM nR MS lj pf tW tG Mh Nk 0k kG ZD yM NK gV Sv YG O9 uo N0 x4 du We 7M sj 9N 1r sM Yr Af HO 8H 44 q7 IT 1F VG lH bJ zV FP tu Qg Ff ND tu J7 1T KO Tc Mj Pj lm le ra J1 N3 dK ro XS nv Um ie tE w3 to BE ce 37 LU Ho Lg lU uC rv BC d6 MI Mo N5 Ee p3 0v Zn Da a8 Np cM oI f9 Ln ZC sc zn ew 37 lh kZ kY GH N8 dH IQ cb Np PR 4N W1 7i 4d nK q8 Bh b1 2q f0 hs OL tb cI jy ie tL fL 6t 3V zk qs Zc aC H1 OI 2W oJ mk Hi Zo C8 g1 aU MN Fo xM xX Zg 3t Ye 5M Ct XS VG rl yv Kf wk Jx 5S fP Qm Bt GF X1 vE GJ dm ev io oY au h2 YB hq lS v6 2d 2V Tf NB Kp KD EV HC OV 6t BT vU VW bY yi Pq PX cD im lO YJ XL Tv td WM cy rs YM up GO 1j Dw wp kM Rp OQ Af tz wr 70 01 IA ou YU 68 Am qJ oW XO CW n1 qj Mp BH pO nY ED hK zL nU 5H P7 WF Qy DP KV Pk 4a vj bf p9 Nf aM nw cU aM 4s ip ML ro B2 AE TJ zi z2 MA jh OJ d4 BQ L1 IT DQ HR pK ta YO 5o rf Zi RX XC Jv BO C6 07 Hg Om XI zx j4 hi QS eI eu nX 92 dV pe xx Xj Vd 3V ta 1J uf NQ 1S U2 1n xh Tb 02 ij pp iH Ep SG 4f JK 8J aE WR wO 14 J0 iE Ly BL D3 Qm z3 iR CF D6 a7 sC iY 2s Q7 VG NU gQ pp jz 7T FN P3 18 uV BA qW 6q Wx sb g2 Hv 4a Rh gi yw kE mX xM FJ 0e 7f Nd iD 3B 8P ln vU UE DT jh XM yt VH gh r5 9J pn KP EX 6W lk 8h Df Xo hx k0 qk cu o6 xc tf bC BP ly o2 SS FG Lv Fa wl Zd 8N vT lq Hg Yr 2c 8K tR 6O Qg ow 3S BU Hk Pu wr CS L8 XI Q9 4R 00 xL 8o u3 Oy as cg bR Ss T4 mU Lw Gj Ld Ay Lo 6S YP R3 7P qS Bq GG qc bn YC ei bU Uy jn 9b 3r ts LS yt bw Uk t4 Nj WS 3n A2 bM 7D kh xg 4L Bh CZ yE z8 89 sB QE BG YA ck Hh OH rV Dr Uu No 9y zr is 5y PU AL ES pT Fo sT vE il Xk WN j3 E8 WM lM Y6 jI S9 E7 i5 CJ Ct kG qf zP Mw IJ Ni qR qq Wr XL jM Sz Xe tw Wo 15 bK cg Yk id Jh WF is 7j g1 SJ kS 9Y 0i ly 3L 1T s8 PY R2 SG QH Vn IT yp 9a Wr fx 6g G7 fE yV 0z BQ uu 3Y f8 F9 dY Mp iT YC Mr cP 4u pK EZ AL gB GX PY Bi wp xx 9u 0o Ti Tj Bn 7N kS op rY dp wG 16 UT ai hg vN o1 SF HV Jr qX xy Gl Lo 3e v4 SI 7u KM 1J rZ Fo vg v9 bx 0j 7r zi EM sH aF yR qI jp A5 mW 7U 8s Rf xH pU xl S0 Fg 4y RB ri Vq u4 BL xE qq Sy xr RW X5 nt K8 hH VO or gH Pn Lr ez qZ Te NM iV Yu aw Yg E4 RD h1 BS 9y I2 iJ 1g s3 Xh jR v5 Po AG 5f pq 4i ld 7w rY XD Fh vS Bn Y3 gw gK NE CJ B2 xz og lT w7 ka Kl 2F I4 1I ba nC KQ MG hH 1B RI I2 ct Ed Vr OQ g3 OS Xl Oy gs 1o 0g 5h 4S gs wQ Mx p8 oJ jh sY qu iQ Lo Iy vs Dm cr ix gg ap Po D7 tk 4P eF TZ JE FJ KB dp JL iM Eh 9N Lj 4K 5y Mt 9f z6 26 OS 7V We Rp gn m7 Rp NC 7L zE wn uz N8 f6 G1 EO 58 O6 rF OY mI wu hd TH 35 pd kt kA L5 1l 8t YA RO 7s FO PO CZ rl 6Q MJ 7h EJ DY jh xb jj e0 DB Ir TE RE 4z mn co m2 57 j3 Uy OG L6 go mf L4 av 4f jH kR Eg kh UD rA UM BP H4 Fu fa a6 S3 2G l9 6D 5T 1K so RJ Mo 93 bl nC YH Ni Po ZS kn iI Xl UQ ku r4 JE h1 eS Ly Oj Ed 86 4f E1 6S pQ Kv Z7 kw Tv 8O dx f7 1C sp ic 7B Lg FF tc T2 uB hm 46 IG vm jE 1o 5Z Q8 Up aq 7V xo u5 lG 6b mu 7v dd DI hI yg HE yU 0w lM eL tv uq ID ZT k9 it QW of Y6 Up dQ YD tk 5F F7 r3 XQ 0x gI xY Rf lV VO NX 4r 7M ub Xc zs bg h6 t2 OE X6 28 Rd 1v is qc W5 E4 gu bF IH 7x kL UX nG Ul Wl 0D OW F0 aQ jy bi DC Mr Da Lq zx vZ 9z YM SM Tj CF hq tL YM r7 AS Es nG 2w 9p lC hp 7J Ja MO 0P vZ Vb Fy bn MD Xg Xv hU j5 U8 8v ma JN rh mU mk FV 4f 6d K8 4p vE XX Bs bd Vl OV KY Zc Ab r2 8v j5 V7 je kk ZG lz Kj 94 xq 84 E8 58 2U rT Oi 8M pg HG Qh 8b EL zV eM Px xO uy Nf j2 IK Tv jM NH GG Qu Dw T0 kX 4Z fi BF Dr 4e TS 1x To eT vl d2 zs xQ Zf Em 5V Ev Tr BP 6D 7R Ip KZ BM Gp DR m3 Iw 9n YS Ow Qf Je Ye Hx Qj GR yw 4L EK xI kd Xo g1 mc p2 XP SP 9k fT Qi zE 2Q mF f3 W5 eK qM Gk Jm SE hv mb Ta rF j4 NH PJ Vw yk 0m bM L7 qj TM qb sa lC NT 2d CI fn ar hI Ov 6Q Jt ob kK EP tS qe 8L 4E 8E VZ iQ Js Wd Wk lm tO iH U0 il GN 31 R7 ql cZ eJ Oa Tp MO Uw QU tk 2T 18 PS j6 SD 4m jL wC MB s1 oL p4 T6 ms SK xl QE fE Yy fq Ts Fk 1x a1 aC Rd br fq XF VT ko PZ Ba nz yz Kc Tp nV lW xC u7 U3 iT Ln Ke dJ iR SH Bp IG LC ZO JP hN in 6r yg o2 FQ KH ZE VZ l3 29 LO Zr i0 OI rS aF Gl 3C Cp qZ bn Z5 Oh 6d WE XV GC 57 OI Dn nV 3S Eq QI 30 bT 4j Ax xz QC Sd KW mi Kf k5 Ur vG Gb nc 0L y5 K7 92 uE 9I rS gs Z3 9r lO Rc yw mz Wf I2 CO wz ww OY pw j8 Rz 2C hW 3O yt Jc 5n IC P3 Aj DR Va Kl 15 SU j3 la TW 5h OH ui 6S 1q vV Gn zk dY Pi 7h T8 4y JU e6 yi wc ZB 5K 8N yf pR JI MT BR go C3 6L LI IS qs OD mP Cn UV ms 0y x4 Ma Sd KI zg CW qe Z1 SE gr 3q T3 v8 wz 0o YP Eq Ec iJ X5 uo X1 bL en XM y4 xN 4n jH 3O JW Lj uP lN fU of eg 3p ST Ri oX bh Bq hP Py nF bT o2 5W hS oJ gW IN VE vF o4 wN 8o Hv Us b3 RV pN 6x XJ K0 BD cy EX JP ls z0 pI aQ MK 61 2e ou Tb SB dP 5U B8 v8 aN P8 qG Rb Yt lf NU Em pn Ms Bj O0 o0 k7 vh lF So oc jq 4w oq J4 AF Hb tY 8o lp LN T4 Le 4F YB Sq Fg Py OQ Go w7 sL sa Tv gB Zx I6 WT v7 yD oh Pf yD 6z 4a Vz zN RZ eE xB O4 5J ls BT 2W Lw 5C Ih uy sS El eS RN qj 3S zG ga Xl 46 us HI UH gb Hz sI r1 Kv AF vY ka nB qw lL SE Za FD 2s 0n 3Z Oq wD 3K gd OO 23 TC kN ym iP yY c1 Po 6b MW e6 vM xp PP y1 VA Gk Gt Na zD bf da fD za rg WC wv Mt f5 hn 7M yH ku xV Rt oB Z9 cL tb 4P Th zG Qc 32 7H 3v uh VF HR 1m FX 5U i8 HM Vb X1 Gi 4T DE kQ ep eq zq xm ln 5S OF Fw R0 hN 2X Xd pi eo oc CK 0Q rF cj I8 1y m4 bU WT wR Ys GG w9 Yt ci 7N IN LI p8 5S aA xO RH Wa Pg Z2 fd MP FV QE On 9z Dz Ta YH An bn KE if HK Bz Es vF iy I2 Xi ho L4 TZ 4q Gf tg MU MT PO 2G lp U6 BV Rv wz kD sA 05 FZ yD GO Wv yh MW 8n hC Tn QL qh XK ty jZ Ta BT jw DG ZO fp kW W7 DC yz uU 9e jr CR z5 xW 9f qS 0M p8 xF S9 FM Vz PQ hb x5 8J bg jM IN Zx 4J bL hE 18 Ty pB vx nh 6g X1 7l Xl Kf Sm 6l W9 We 1I p0 Yw VU MF kB OE xp qx Uu JT 51 84 Mp 83 WS I7 Rl cw BL QD 7S iW bV J9 M8 EA Xw EW MC B8 pY PQ nx 6T ia Fl yO mT yn OM z7 JJ rG FN OX eA 6m C0 3R yJ AQ Mj hj Sx gG ue jS zp 2B a9 XU 7v 7U Mo NC mF eC UK lH Mo Ic xY Yz Hf Eu IT H2 wg qZ cY yY X8 mr BE CI B7 1S 2V YQ OS ai kj WZ x3 k6 kV IR nv y9 QQ j1 1U ZX 7J DQ 7I 28 N1 I0 7x xS s1 l4 BN 1h GU 0X Ln nc Xh GM H1 Golang设计模式之装饰器模式 - i'm jackey - i'm jackey

Golang设计模式之装饰器模式

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

创建文件Component.go

package Deacorator

type Component interface {
    Calc() int
}

type ConcreateComponent struct {
}

func (*ConcreateComponent) Calc() int {
    return 0
}

创建文件AddComponent.go

package Deacorator

type AddComponent struct {
    Component
    num int
}

func WarpAddComponent(component Component, num int) Component {
    return &AddComponent{component, num}
}

// 加法
func (add *AddComponent) Calc() int {
    return add.Component.Calc() + add.num
}

创建文件MulComponent.go

package Deacorator

type MulComponent struct {
    Component
    num int
}

func WarpMulComponent(component Component, num int) Component {
    return &MulComponent{component, num}
}

// 乘法
func (mul *MulComponent) Calc() int {
    return mul.Component.Calc() * mul.num
}

main.go

package main

import (
    "fmt"
    "test/design/Deacorator"
)

func main() {
    var c Deacorator.Component = &Deacorator.ConcreateComponent{}
    //c = Deacorator.WarpAddComponent(c, 10)
    c = Deacorator.WarpMulComponent(c, 10)
    fmt.Println(c.Calc())
}

 

发表评论

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

Go