feat: add Go embed React single binary article (Go 工程实践 #3)

This commit is contained in:
2026-08-16 21:28:57 +08:00
parent ca2309dda0
commit 60f3412a55
2 changed files with 267 additions and 0 deletions
@@ -0,0 +1,42 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1067" height="600" viewBox="0 0 1067 600">
<defs>
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#f6f4fb"/>
<stop offset="1" stop-color="#e7f0f7"/>
</linearGradient>
<linearGradient id="go" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#00add8"/>
<stop offset="1" stop-color="#0087a8"/>
</linearGradient>
</defs>
<rect width="1067" height="600" fill="url(#bg)"/>
<text x="533" y="84" text-anchor="middle" font-family="sans-serif" font-size="40" font-weight="700" fill="#2b3340">Go 单文件打包进阶</text>
<text x="533" y="126" text-anchor="middle" font-family="sans-serif" font-size="24" fill="#8090a0">React 前端 + go:embed + 交叉编译</text>
<rect x="96" y="196" width="230" height="96" rx="16" fill="#ffffff" stroke="#d8d2ec" stroke-width="3"/>
<text x="211" y="238" text-anchor="middle" font-family="sans-serif" font-size="28" font-weight="700" fill="#5b5568">dist/</text>
<text x="211" y="266" text-anchor="middle" font-family="sans-serif" font-size="15" fill="#8a84a0">Vite 构建产物</text>
<path d="M346 244 h64" stroke="#7c5cff" stroke-width="4" fill="none"/>
<path d="M402 238 l12 6 l-12 6 z" fill="#7c5cff"/>
<rect x="418" y="196" width="230" height="96" rx="16" fill="url(#go)"/>
<text x="533" y="236" text-anchor="middle" font-family="monospace" font-size="24" font-weight="700" fill="#ffffff">go:embed all:dist</text>
<text x="533" y="266" text-anchor="middle" font-family="sans-serif" font-size="15" fill="#d8f4fb">编译期塞进二进制</text>
<path d="M668 244 h64" stroke="#7c5cff" stroke-width="4" fill="none"/>
<path d="M724 238 l12 6 l-12 6 z" fill="#7c5cff"/>
<rect x="740" y="176" width="240" height="136" rx="18" fill="#ffffff" stroke="#7c5cff" stroke-width="4"/>
<text x="860" y="224" text-anchor="middle" font-family="monospace" font-size="24" font-weight="700" fill="#5b3fd4">magic-img</text>
<text x="860" y="256" text-anchor="middle" font-family="sans-serif" font-size="15" fill="#5b5568">单文件 · 约 26MB</text>
<text x="860" y="284" text-anchor="middle" font-family="monospace" font-size="14" fill="#8a84a0">windows/amd64 · linux/amd64</text>
<g font-family="sans-serif" font-size="18" fill="#5b5568">
<rect x="96" y="404" width="275" height="74" rx="12" fill="#ffffff" stroke="#e3ddf3" stroke-width="2"/>
<text x="233" y="434" text-anchor="middle" font-weight="700">HashRouter + base /dist</text>
<text x="233" y="460" text-anchor="middle" font-size="14" fill="#8a84a0">无需 SPA fallback</text>
<rect x="396" y="404" width="275" height="74" rx="12" fill="#ffffff" stroke="#e3ddf3" stroke-width="2"/>
<text x="533" y="434" text-anchor="middle" font-weight="700">index.html no-store</text>
<text x="533" y="460" text-anchor="middle" font-size="14" fill="#8a84a0">升级立即生效</text>
<rect x="696" y="404" width="275" height="74" rx="12" fill="#ffffff" stroke="#e3ddf3" stroke-width="2"/>
<text x="833" y="434" text-anchor="middle" font-weight="700">GOOS=linux GOARCH=amd64</text>
<text x="833" y="460" text-anchor="middle" font-size="14" fill="#8a84a0">无 cgo,任意平台交叉编译</text>
</g>
<text x="533" y="548" text-anchor="middle" font-family="sans-serif" font-size="18" fill="#a49cc0">纯 Go 依赖(modernc SQLite)是跨平台交叉编译的前提</text>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB