Skip to content

rabarar/nbreadline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nbreadline

Non-blocking readline() package for Golang

This is a simple package to implement a non-blocking readline in Go using channels and Go-routines

Example use:

import "github.com/rabarar/nbreadline"


func reader() {

	var r nbreadline.Reader

	r.New()
	defer r.Close()

	for {

		cmd, err := r.ReadLine()
		if err == nil {
			fmt.Printf("received cmd: %s", cmd)
		} else {
			if err == io.EOF {
				fmt.Printf("received EOF\n")
				break
			}
		}
		time.Sleep(time.Millisecond * 50)

	}
}

About

Non-blocking readline() package for Golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages