Skip to content

Add support for multiple old:new replace mappings #18

@carterpeel

Description

@carterpeel

Hello,

I'm curious to know if it'd be possible to implement the ability for ios.NewBytesReplacingReader to ingest multiple old:new token mappings in the ios package.

This is obviously the current functionality of the interface:

package main
import (
    "io"
    "os"
    "strings"
    "github.com/jf-tech/go-corelib/ios"
)
func main() {
    r := strings.NewReader("foo bar baz")
    replacer := ios.NewBytesReplacingReader(r, []byte("foo bar baz"), []byte("baz bar foo"))
    io.Copy(os.Stdout, replacer)
}

Would it be too much trouble to get the functionality shown below?

package main
import (
    "io"
    "os"
    "strings"
    "github.com/jf-tech/go-corelib/ios"
)
func main() {
  r := strings.NewReader("foo bar baz")

  replacer := ios.NewBytesReplacingReader(r, [][]byte{[]byte("foo"), []byte("bar"), []byte("baz")}, [][]byte{[]byte("foo-new"), []byte("bar-new"), []byte("baz-new")})

  io.Copy(os.Stdout, replacer) // returns "foo-new bar-new baz-new" to stdout
}

Thanks a bunch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions