SVGo

A Go library for generating Scalable Vector Graphics (SVG) directly from code, covering shapes, paths, gradients, filters, and animation.

Library
Go
vv0.0.0-20211024235047-1546f124cd8b
2,250stars
CC-BY-4.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
40/100Fair
Development Activity0
Maintenance0
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
59/100Fair
Architecture65
Code Quality40
Innovation55
Learning Curve75

SVGo is a Go package that generates SVG 1.1 output by writing directly to any io.Writer, letting a Go program produce vector graphics without a separate design tool or template engine. The API exposes shapes (circle, rect, polygon, line), text, general/arc/bezier paths, linear and radial gradients, coordinate transforms (translate, rotate, scale, skew), SMIL animation elements, and the full set of SVG filter-effect primitives (feGaussianBlur, feColorMatrix, feTurbulence, and more), all as methods on a single SVG struct.

Because output is just bytes written to a Writer, the same code path works equally well printing to stdout, writing a static .svg file, or streaming SVG directly from an HTTP handler with a set Content-Type header. The project’s own example directory doubles as its documentation: dozens of small Go programs demonstrate bar charts, bullet graphs, data plots, animated diagrams, and generative art, each built purely from SVGo’s shape and path calls.

What You Get

  • A full method set for SVG shapes, text, and general/arc/bezier paths
  • Linear and radial gradient and filter-effect (feGaussianBlur, feColorMatrix, feTurbulence, etc.) support
  • Coordinate transform helpers: translate, rotate, scale, skewX/Y, paired with Gend() to close a group
  • SMIL animation methods (Animate, AnimateMotion, AnimateTransform variants) for basic client-rendered motion
  • Output is just an io.Writer, so the same calls work for stdout, a file, or an HTTP response body
  • Dozens of runnable example programs (charts, gradients, generative art) that double as usage documentation

Common Use Cases

  • Generating charts, plots, and bullet graphs as SVG from a Go backend without a JS charting library
  • Serving SVG images dynamically from an HTTP handler based on request parameters
  • Producing diagrams, data visualizations, or generative art as part of a Go command-line tool
  • Rendering simple vector illustrations (logos, icons) programmatically instead of hand-editing SVG XML
  • Sketching and iterating on SVG output interactively via the bundled svgplay tool

Under The Hood

Architecture The library is a single flat package (svg.go, ~1080 lines) built around one exported SVG struct wrapping an io.Writer; nearly all of its 120-odd methods are thin, stateless calls to internal print/printf/println helpers that format and write SVG markup directly, with no intermediate DOM, buffering layer, or validation pass — each method call is a direct, one-way translation to output bytes, so the caller is fully responsible for correctly nesting Start()/End(), Gstyle()/Gend(), and similar open/close pairs. This is a deliberately minimal design: there is no abstraction to swap or extend, and the doc.go/example programs (svgdef, animate, svgplay, and dozens more under the repo root) serve as the closest thing to an integration layer, each just importing the package and calling its methods in sequence.

Tech Stack The module (go.mod, Go 1.15) has effectively no runtime dependencies beyond the Go standard library (fmt, io, encoding/xml, strings); the only listed requirements are github.com/ajstarks/deck/generate and honnef.co/go/tools, both used by auxiliary example/tooling binaries rather than the core svg package itself. There is no build system beyond go build/go install, no external service integrations, and no web framework — the library’s only I/O contract is the io.Writer interface, which is what lets the same code target stdout, a file, or an net/http.ResponseWriter interchangeably.

Code Quality There are no _test.go files anywhere in the repository, so the project has no automated test coverage and no CI configuration; correctness is implicitly exercised only through the example programs, which compile but are not run as part of any check. Method and type names are consistent and follow SVG’s own terminology (Circle, Gtransform, Offcolor, Filterspec), and the exported API is fully commented for godoc, but internal error handling is minimal — writer errors from fmt.Fprint* are returned but rarely checked by callers, and there is no input validation on style-string arguments.

What Makes It Unique SVGo’s distinguishing choice is treating SVG generation as direct, uncached streaming to any io.Writer rather than building an in-memory document tree to serialize later — a comprehensive one-package API for shapes, gradients, transforms, filter primitives, and SMIL animation with essentially zero dependencies. This makes it lightweight and predictable for output-only use cases (batch chart generation, HTTP image handlers) at the cost of offering no read-back, editing, or validation capability once markup has been written.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search