Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
/ gio Public archive

Generic aware io interfaces, in-memory pipe, generic aware pipeline and unix-like pipeline working on streams of bytes.

License

MIT, BSD-3-Clause licenses found

Licenses found

MIT
LICENSE
BSD-3-Clause
LICENSE.BSD
Notifications You must be signed in to change notification settings

gomoni/gio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

moved to https://codeberg.org/gonix/gio

gio

  • gio: Generic-aware io interfaces like gio.Reader[int], generic-aware in-memory pipe gio.Pipe[string]. Forked from Go stdlib.
  • gio/pipe: Generic-aware pipeline with a standard input output streams and filters. Enable writing unix-like utilities working on top of native Go types.
  • gio/unix: byte stream aware pipeline with a standard input output streams and filters. Works like traditional unix tools.

Example

An equivalent of cat | wc -l using a native Go types and channels under the hood.

	out := &StringBuffer{}
	stdio := NewStdio[string](
		nil,
		out,
		os.Stderr,
	)

	err := pipe.NewLine[string]().Run(ctx, stdio, cat, wc)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(out.String())
	// Output: 3

os/exec wrapper

gio/unix has a *exec.Cmd wrapper allowing to run any system command as a Filter

	stdout := bytes.NewBuffer(nil)
	stdio := unix.NewStdio(
		nil,
		stdout,
		os.Stderr,
	)

	cmd := unix.NewCmd(exec.Command("go", "version"))
	err := cmd.Run(ctx, stdio)
	fmt.Println(out.String())
	// Output: go version 1.20 linux/amd64

TODO

  • explore the Transform[F, T any] option allowing type conversion

About

Generic aware io interfaces, in-memory pipe, generic aware pipeline and unix-like pipeline working on streams of bytes.

Resources

License

MIT, BSD-3-Clause licenses found

Licenses found

MIT
LICENSE
BSD-3-Clause
LICENSE.BSD

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages