GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ragsagar/netstringer: Golang package to encode or decode stream of netstring

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
netstringer.go
netstringer.go
 
 
netstringer_test.go
netstringer_test.go
 
 

Repository files navigation

Netstringer

Golang package to encode or decode stream of netstring

To install package:

go get github.com/ragsagar/netstringer

Examples:

To encode a data into netstring
//main.go
package main

import (
	"fmt"
	"github.com/ragsagar/netstringer"
)

func main() {
	input := []byte("hello world!")
	output := netstringer.Encode(input)
	fmt.Println(string(output)) // 12:hello world!,
}
$go run main.go
12:hello world!,
To decode a stream of incoming data into netstring
// main.go
package main

import (
	"fmt"
	"github.com/ragsagar/netstringer"
)

func main() {
        // To mock the incoming stream of data.
	inputs := []string{
		"12:hello world!,",
		"17:5:hello,6:world!,,",
		"12:hello ",
		"world!,",
	}
	decoder := netstringer.NewDecoder()
	go func() {
		for _, input := range inputs {
			decoder.FeedData([]byte(input))
		}
		close(decoder.DataOutput)
	}()

	for output := range decoder.DataOutput {
		fmt.Println(string(output))

	}
}
$go run main.go 
hello world!
5:hello,6:world!,
hello world!

About

Golang package to encode or decode stream of netstring

Topics

gogolangnetstring

Resources

Readme
MIT license
Activity

Stars

5 stars

Watchers

3 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.