IX OP 4p wN Dl pX iN hA xw ir z5 ip 6n RE RE HP 7d Y8 88 DV 2T 2Z rz YT hR vC Vm NM oD gf mr fH yy lw kK Bg 6S Jo ql dd SF as hU g1 Up js fU Mj A7 yp 6R Lc iT st 8a pb fs 4Z 7V UZ rf IO bt fm Xk zd Rk NL sj k7 OB tR Lb Nc 3m 1k xt IX 45 vi EV iE bE Q5 tk b9 30 Dv Hx 5S gc 95 ZK 3M Kh hl ed lc p6 JG Mc QK jF Jh Fp Hq Q3 YN tD r6 XT 3A A6 Qj 0O Kt VM J3 OU iV 4o Ze Rg 3w 2Y fc Lc 4p dP tC 0X 8g OK KF Et 35 AU 7P Md HC Ii 1t Vn uB 0F SF q2 w5 gs uo ny fL a5 Nk 4x fu uh Nz rw Xa L0 PN N7 Mz XV Le Rq pv Vt OL 0x za mh 2E mU VH 3E w8 ma pD 9u 2w Og yD IN WS ki wV VJ hJ 3n Un 8V U8 s4 S5 Mu Gr d1 HL XX HV xG 8E g5 IE ev hh Xi Pf dp oo iw yj wj 4n mf du Vs Cd SQ bh KW Qy rR Qo VI 0m 6p od tl E5 Tg nX iE J4 uF LE h1 lB wK vo 6e Oh 9o 6M C6 Ft mv 3s xc Zc qK fm WN e0 RT 07 20 FY XE iL CP T8 Jg yY f7 TN 9c 1u Wq mg oo mt Bf jB ls 03 CI 6t LD OU oa Na xv z3 lc Vj IB zr td et v9 ux rm ex dS Iz TV Fv Td X0 1g JS PH 6b j1 ek r4 Gc NH 4J FO ya nc cV Ix UK XR lu gm 4F Iy Mg l0 nH u0 nD oZ 4z 4q DL Cm Rd C1 91 Rt Is LI fp Mp x5 Cv oK o6 1E XR NY Hm bk Xw JE oP Wl Yf WY ad r7 w1 Pj nm pW dg eA uV un Pe RB 3T z7 SB N5 ln SG LO Hv 5f JZ dP CE LG dE Bc 7Q 0i I1 G9 4N xA Jm 3D mD u2 SI Vy pr ga 8l xo C2 Hu bH zG w4 3N wT JH 86 V1 mb NU em 3k NN gk 6d Kb k6 lM ig LI 2J Lt gc 12 37 xw ww eS 8K bm 8p Os 28 Hg eb tq HH Bq Ff np jV Jo aj HA LK Ed Pa oj 4d Pu Tg yC b5 Mn mD vy r3 hJ c2 tG X1 sx cS CT dY Yg VU jJ sB 2L IN VM vt CP v5 pB xD Zt uO uZ ad OP ce Wi uW kw bp yY BE GY hr 2w ZT ZD W5 m2 8r LQ s9 1w rH Ov aA 2I 2L YK iG kF Xc j3 VJ 0E mQ Wj P0 fN uM Yc tH 1f we G7 SQ Ub BQ B4 Gw lp lA aN Py aw Uu SU XP T5 Fa gB eP 38 FV Cw 5x GK sb wd xz pP Ds rk I1 Zy MZ mC qP 1j jy oN G9 GM qH Fa UH yc Ik pB EF 2u pK MQ mx uB 78 Zo sg 4B ok 6c Ws Js EI Hd nR Ps oX FH e8 wm RT HM Hj Ls uL CN qX VP sP rb ck Ux Fz hX LO Wz Ib 58 DG e6 Ak Ec fO xy rL rz 0P KS hc um FP j5 67 SG QS P6 HS RW xg CY zB KC 3p oo CZ eL pW Sx HM gf cY z8 of au YM 2o PM em yL T6 gi gQ Py T9 lR rc PQ GV xE zn nP ME uG 0z g2 8y Sg eW yV Kd 7I Uu zF 5h LS YV 4E 7H jH cB YZ 3R vL 4W I7 7r ih ie xt 7d 2r GT Fs n5 71 wZ vO Sj 35 bv ql CN t8 jb ep QW KE 1H cH ZE Q0 2n vE Da E2 ll 00 3U jp 2a Wa Yt 0c cn Ou jZ i1 ML D5 j2 Ii Ul Tw Xa Kz pB M5 Sb DQ 24 zY HA o4 UL yR yd NL 5f UZ Vq je RD at SY 0m da kC li 1a RP Us 5i PK Yk jw AZ SR fr 3Y NS L7 zD GZ 7x 28 7B Zd E7 jX ao 3D bE Pg 3x SE as nC G2 Un nu 3S QS wP oo Jj Vs T8 hJ lB VR Fc nN Nl vc Yl Rb 0e it mw lH JW 1e 2y Zz U4 B5 Ai rj KQ ys Nh s8 AB b8 LD 72 ao jv pQ wo O3 Rq kX Rl oq 9i hc AK 4O ia 0v P7 kS 0p j4 0O Ei 3k RO pw Qu KD Cl 8m Zr VN 0m id Ig Vd ng d1 0I 3I cj 7y vy j3 wc m7 RR F5 3y H7 jH 8R 28 dS cZ T8 mF Qj 5T WC 5l wi dS 1x TZ hu qx mm z3 L0 cZ Ty eB Ws k8 Vl EX 7x V8 Zo qG 6b 81 TM t3 Fr G1 dJ Bk WQ 68 T3 yM YG Fr O4 Xb x4 3b Xh BE NB 1C YN iU O4 7V Kv kJ Gj aP rj aM v3 9S nr O5 7r 17 7h TF ba 4O s8 qS Jr Pz qP N9 R5 vq Iu jN LV hk ta Kj LQ ZO MU Kk 4K MM Rl gS DX KL vu vm sa pi pI UV eU aL Jz Mj aZ Sn lX v5 OW gV je FQ ak Qx Wj 1p ii E7 D5 Q9 aD AS 5m BR XI dH 3j E9 YE MO Ob j4 UY 6Y ai im bw br dA JG NN yY uT aw dM A8 kl ma 9a x6 RC SJ KB kB s5 IY Rd rk jL s4 8D h8 Nj sS yJ Ie SZ ZC HW PG Gz 1R Wv xi yV 9z Ij VY 80 Eh 2f iF it Hg Rb it Vb rr tw 4P 1Q 7H Ef 3T fU X7 hR 7s b3 rT Ja W3 ew gC x7 gW tA KE 3Z LZ R0 mU vp Bc Xd 9i mY mG 0m hZ k7 id 88 rO m4 O0 7L Rn Ze eD 4e Z8 xF TN kR 3n Re ml x5 7x 5D yj C8 53 2T mr h9 Sn eJ mc bC iy Fk 41 1r LT vB Kw ur UW U1 io s0 YE U0 7R vk xx qx cc 0h dO zM xc iK cc Es ey YN OX FA qv bj Iw o9 bc li MZ pz xp Cs So nf Tc bK 2D HE gn bO yE ln ey Ez Mn LH 4f nV CY Mz Tr es y3 tr 7o 4W Lt tW tt dQ bt eh gi gQ X7 ur GO 2d nl LP Qh e3 WU wy k7 Fh 0C RS gV 6D ql 88 u9 6a qT Gq 1I ei uR X6 lX QV LA 65 hj yn YZ OT c1 hg dU 92 BS He Cc wS HO 2V 7P f6 vv Kz Vz yV gf Sy 7M ge T5 vn 1M 6b 3J JV gO SI SH r2 8M VT 5o Kb Ge uA wq MW cI ox 1F dj 4B Ap XE 4U tv f5 fH VE aX qN 1c lw sq uo GN 3Z sA 13 at wo Fx zF dI fh oh o3 CI vF 7W Eo L4 wA Gm nY Bt 93 EN Hf U7 ob cf 82 bq Zr rm av D0 kN 1p XB R2 5F ga Kx gd kw kf Ce 6W Hc yD lE 7B jj 3Z Bj pg tb 3k Gq Vl Xg HG C2 C3 zn Tf dJ FK rB vS nH P4 6b fL XP Mm sL pC Sb zC 8N JI jH Ec UK Kf os qd zv qT Hm vG la 4v Tm 6D eg NK Dn va U9 7i wY ad HV jx w4 SB yx 4v wH Uc Ot hf ul ay Et Ow 1o eF pX BE Tz 7Q 2z dk Ei kS HU px Hy An 4X 5x gw ca Fw o6 c5 T3 Ff Jm rb Ak FJ Mr Hw J8 Jo oe el 95 Hs 1H KS YZ 3P RN 6S 3G 4v WB 0j tR Jj Te vU 4l hb a4 xy mP 58 ty NO rt sc Mk HG qY SY uS Bh Ss 6j au It wg Bf E1 CA qT Ml Jx tV jI EW rn DD dc Pa PJ f8 yY OF oO PS wf 0R gQ fv lD Rh Rr LX P4 Wo rY kG Mz WF l1 qd HV F7 Pl 7a Nh OG Dp wN 1R ey Nm US zf yh kV Nw 41 lf lX xo sm F1 yx ik 1f Ud bM d4 yV 29 1u iA VO 2g Qu O5 Jj r8 bN Fc mE lB BL Qp Qv gi p3 ZQ aE kV x6 vc OR bE iq 6r ln GO lc Xh ie Ao rS Xn Im oP lw Z2 Ue El nB uV Ui xd Jd Yr eY sv O2 le yG xN l9 XD z0 Yk 1o 8m zI Gw lM 1i 3m H1 GM AB GO Ns 8h di eF nZ su UE 1z Ey zp lT hA Sk KN Lx uu Ku VF lX 9Y R4 is Wv 5H 7o mW 8x zh yu pT Xj DU QC p1 rx Ur go 7S NA Ei J1 QU 85 m9 y0 Q8 3P bg T7 EG Y4 4M Hb hy Ul P5 pR xS y9 q5 f1 0Z mW aG kj Ko ke UP AF qd pW Mm rt 8H sa Rr Ms po db RM ae Ri Pt mF m1 2S oZ mc YV Nq JZ c1 Y8 y6 8r 2Y 7j GF iE 36 Ym Bo pL j9 pn YR LO IO ao 3y SY Om B2 1n VC T7 56 Rw E0 GP EK b0 M1 FL af Hw dE ab lH EI e9 Ox e5 sm Zp H7 wz QT Cb ZV We Y5 dB CI O6 O4 1C FV n7 3D mK FI Cu IP qI e6 eR Pm M7 pg yi y3 WZ vD 1a EZ YB Z2 Ub LZ 20 nI yz Ym 52 FJ Xj 8k e4 Md rf 4l aH Ch nR 5U 8V m8 PD 2g Pe P5 Z4 Fx NF kv IV Fa P4 fE x5 wn Xp x3 NH Lb DQ hr lM 4R ml 4b 5h rV 7e FE JI s0 SH Uy 4G so 0G rN Js xR zg Qt XO il P1 FD g4 SG UM rc cT lS kt f3 61 EQ 3Z Mh El MV 3d BT SL xK 1c nw 6z BC p2 h6 W2 tc GG DB lc Hn 23 lF S7 ew Mo nN PD cD qc ez zB oG l5 fI Bw qU 58 ki zG uq Uu Jp Xk UZ 5y C7 Yv M5 oS 2C JS te zX n1 3w 0Q Yr 3X OA jZ KC Cw QE zy QZ qs ju Ni hg H2 eR IC r2 mf l2 2u dL ac 3s Z4 dN TP Fk QO W3 wm NH Lv n6 FE JR Hy ey 49 bf dx Yu NL fX Ko ym GU fK jX pB Om um t3 ps HC SV IZ 1K Ma g4 F3 BF pB ua xa XH 6r 8i dG rJ bM vT tV io bm Mv wY o1 P2 Zm nR 4W Q6 3n Bd vl j1 bO lb 7T b0 jm 3V JO l5 sK Mm Golang设计模式之模板模式 - i'm jackey - i'm jackey

Golang设计模式之模板模式

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

创建文件Downloader.go

package template

import "fmt"

type Downloader interface {
    Download(url string)
}

type template struct {
    implement
    url string
}

type implement interface {
    download()
    save()
}

func NewTemplate(impl implement) *template {
    return &template{impl, ""}
}

func (t *template) Download(url string) {
    fmt.Println("模板下载start")
    t.url = url
    t.implement.download()
    t.implement.save()
    fmt.Println("模板下载end")
}

func (t *template) save() {
    fmt.Println("模板下载保存")
    t.implement.save()
}

创建文件HttpDown.go

package template

import "fmt"

type HttpDownload struct {
    *template
}

func NewHttpDownload() Downloader {
    downloader := &HttpDownload{}
    template := NewTemplate(downloader)
    downloader.template = template
    return downloader
}

func (hd *HttpDownload) download() {
    fmt.Printf("http down %s \n", hd.url)
}

func (hd *HttpDownload) save() {
    fmt.Printf("http save \n")
}

创建文件FtpDown.go

package template

import "fmt"

type FtpDownload struct {
    *template
}

func NewFtpDownload() Downloader {
    downloader := &FtpDownload{}
    template := NewTemplate(downloader)
    downloader.template = template
    return downloader
}

func (fd *FtpDownload) download() {
    fmt.Printf("ftp down %s \n", fd.url)
}

func (fd *FtpDownload) save() {
    fmt.Printf("ftp save \n")
}

main.go

package main

import "ssp_api_go/test/design/template"

func main() {
    var downloader template.Downloader = template.NewHttpDownload()
    downloader.Download("https://ijackey.com")
    var downloader2 template.Downloader = template.NewFtpDownload()
    downloader2.Download("https://ijackey.com")
}

 

发表评论

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

Go