Go's standard library covers most of what a data processing job needs: encoding/json and encoding/csv parse common formats, bufio streams large files line by line, slices, maps and sort order and group records, and sync with goroutines processes batches in parallel. You can build a complete extract, transform and load pipeline without a single third-party dependency.
The examples below target current Go (1.22 or newer) and use slices, errors and context-friendly patterns instead of deprecated helpers such as io/ioutil.
encoding/json maps JSON to structs through field tags. Unmarshal suits small payloads, while json.NewDecoder reads from any io.Reader and can walk a large stream of values without loading everything into memory.
For tabular input, encoding/csv handles quoting, embedded commas and custom delimiters. Call Read in a loop rather than ReadAll when the file is large, because ReadAll keeps every record in memory.
Both packages also have encoders (json.NewEncoder, csv.NewWriter), so the same program can read one format and write another. Remember to call Flush on a csv.Writer and then check Error.
Reading a multi-gigabyte log file with os.ReadFile allocates the whole file. bufio.Scanner reads one line at a time with a small buffer, and bufio.Writer batches small writes into fewer system calls.
The default maximum token size is 64 KiB, so a longer line makes Scan stop and Err return bufio.ErrTooLong. Raise the limit with Buffer as shown, or use bufio.Reader.ReadString when line lengths are unbounded.
Since Go 1.21 the slices and maps packages provide generic helpers, so you rarely need sort.Slice any more. Grouping is a plain map, and math supplies the numeric functions.
slices.Sorted(maps.Keys(m)) needs Go 1.23 or later. On Go 1.21 or 1.22, collect the keys into a slice and call slices.Sort. The standard library has no data frame type, so for heavy statistics you write small helpers like the ones above or add a numeric library.
CPU-bound transforms scale across cores with a worker pool. Send work through a channel, start a fixed number of workers, and close the results channel once a sync.WaitGroup says every worker is finished.
Result order is not guaranteed, so attach an index to each job when order matters. Use context.Context to cancel a pipeline early, and pick a worker count near runtime.NumCPU() for CPU-bound work.
| Task | Package | Notes |
|---|---|---|
| Parse or emit JSON | encoding/json | Use a Decoder for streams |
| Read or write CSV | encoding/csv | Read row by row for big files |
| Binary formats | encoding/binary, encoding/gob | Fixed-width records, Go-to-Go transfer |
| Line-oriented streaming | bufio, io | Raise the Scanner buffer for long lines |
| Sort, search, deduplicate | slices, maps, sort | Prefer slices on Go 1.21+ |
| Logging a pipeline | log/slog | Structured logs since Go 1.21 |
| Parallelism | sync, channels | Bound the number of workers |
It is enough for extract, clean, aggregate and export jobs. For data frames, plotting or advanced statistics you will want a library such as Gonum, because the standard library only offers basic math.
No. io/ioutil has been deprecated since Go 1.16. Use os.ReadFile, os.WriteFile, io.ReadAll and os.ReadDir instead.
Stream it: bufio.Scanner, csv.Reader.Read in a loop, or json.Decoder.Decode per value. Keep only running aggregates, not the records themselves.
It is adequate for most workloads. Reusing decoders and structs reduces allocations, and you can profile with pprof before reaching for a different library.
Use encoding/json and encoding/csv to read and write data, bufio to stream it, slices, maps and math to transform and summarise it, and goroutines with a sync.WaitGroup to parallelise the work. Avoid the deprecated ioutil helpers, stream anything large, and move to a third-party library only when you need data frames or heavy numerics.