Skip to content

Saranyan-98/GoTextReplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoTextReplace

GoTextReplace is a powerful Go package designed to facilitate bulk text replacement, making it effortless to find and replace content in multiple files. Whether you're managing configuration files, templating, or any other text-based document manipulation, GoTextReplace has you covered.

Minimum Go Version Requirement: 1.15

Quick Start

To quickly get started with GoTextReplace, follow these simple steps:

  1. Import the package:

    import "github.com/Saranyan-98/GoTextReplace"
  2. Initialize the TextReplace struct with your configuration:

replacer := GoTextReplace.TextReplace{
    Filename: "sample.txt",
    YAMLfile: "tags.yaml",
}
  1. Use the TextReplace method to execute bulk text replacement:
err := replacer.Run()
if err != nil {
    fmt.Println(err)
}

Sample YAML file

Here's an example of a YAML configuration file (tags.yaml):

name: saranyan
company: XYZ

Sample Text file

The source file (sample.txt) contains handlebar tags that need replacement:

My name is {{name}} and I work at {{company}}

Custom Output File

You can also specify a custom output file and path for the modified content:

replacer := GoTextReplace.TextReplace{
    Filename:       "sample.txt",
    YAMLfile:       "tags.yaml",
    OutputFileName: "final.txt",
    OutputPath:     "./output",
}

err := replacer.Run()
if err != nil {
    fmt.Println(err)
}

Releases

No releases published

Packages

No packages published

Languages