diff --git a/TemplatedProject.go b/TemplatedProject.go index 3a741d8..e780fb2 100644 --- a/TemplatedProject.go +++ b/TemplatedProject.go @@ -22,8 +22,6 @@ const ( PLACEHOLDER_ITERATIVE_RECURSE_LN = "${{recurse}}\n" archiveMarker = ".zip" - - MAXIMUM_BUFFERED_LENGTH = 8192 ) /* @@ -235,7 +233,6 @@ func (this *TemplatedProject) replaceFileContents(inPath, outPath string, mode o */ func (this *TemplatedProject) replaceStringParameters(input string, parameters map[string][]string) string { - var resultBuffer bytes.Buffer var characters chan rune var sequence, separator, parameterName string var parameterValues []string @@ -244,6 +241,8 @@ func (this *TemplatedProject) replaceStringParameters(input string, parameters m characters = make(chan rune) go readRunes(input, characters) + resultBuffer := bytes.NewBuffer([]byte{}) + for { sequence, exists = readUntil(PLACEHOLDER_OPEN, characters) @@ -451,17 +450,18 @@ func readRunes(input string, results chan rune) { */ func readUntil(pattern string, characters chan rune) (string, bool) { - var buffer bytes.Buffer var sequence string var character rune var index int var done bool + buffer := bytes.NewBuffer([]byte{}) + for { character, done = <-characters - if !done || buffer.Len() > MAXIMUM_BUFFERED_LENGTH { + if !done { return buffer.String(), false }