Removed the sentinelSignaller chan from the vmware builder parsers and its unit-tests, and also commented all of the goroutines that are used.
This commit is contained in:
parent
159ea595df
commit
f17007d546
File diff suppressed because it is too large
Load Diff
|
@ -7,35 +7,29 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func consumeString(s string) (out chan byte, eos sentinelSignaller) {
|
func consumeString(s string) (out chan byte) {
|
||||||
eos = make(sentinelSignaller)
|
|
||||||
out = make(chan byte)
|
out = make(chan byte)
|
||||||
go func() {
|
go func() {
|
||||||
for _, ch := range s {
|
for _, ch := range s {
|
||||||
out <- byte(ch)
|
out <- byte(ch)
|
||||||
}
|
}
|
||||||
close(eos)
|
|
||||||
close(out)
|
close(out)
|
||||||
}()
|
}()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func uncommentFromString(s string) string {
|
func uncommentFromString(s string) string {
|
||||||
inCh, eos := consumeString(s)
|
inCh := consumeString(s)
|
||||||
out, eoc := uncomment(eos, inCh)
|
out := uncomment(inCh)
|
||||||
|
|
||||||
result := ""
|
result := ""
|
||||||
for reading := true; reading; {
|
for reading := true; reading; {
|
||||||
select {
|
if item, ok := <-out; !ok {
|
||||||
case <-eoc:
|
break
|
||||||
reading = false
|
} else {
|
||||||
case item, ok := <-out:
|
result += string(item)
|
||||||
if ok {
|
|
||||||
result += string(item)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(out)
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,21 +101,17 @@ func TestParserUncomment(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func tokenizeDhcpConfigFromString(s string) []string {
|
func tokenizeDhcpConfigFromString(s string) []string {
|
||||||
inCh, eos := consumeString(s)
|
inCh := consumeString(s)
|
||||||
out, eoc := tokenizeDhcpConfig(eos, inCh)
|
out := tokenizeDhcpConfig(inCh)
|
||||||
|
|
||||||
result := make([]string, 0)
|
result := make([]string, 0)
|
||||||
for reading := true; reading; {
|
for {
|
||||||
select {
|
if item, ok := <-out; !ok {
|
||||||
case <-eoc:
|
break
|
||||||
reading = false
|
} else {
|
||||||
case item, ok := <-out:
|
result = append(result, item)
|
||||||
if ok {
|
|
||||||
result = append(result, item)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(out)
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,16 +214,14 @@ func consumeDhcpConfig(items []string) (tkGroup, error) {
|
||||||
out := make(chan string)
|
out := make(chan string)
|
||||||
tch := consumeTokens(items)
|
tch := consumeTokens(items)
|
||||||
|
|
||||||
end := make(sentinelSignaller)
|
|
||||||
go func() {
|
go func() {
|
||||||
for item := range tch {
|
for item := range tch {
|
||||||
out <- item
|
out <- item
|
||||||
}
|
}
|
||||||
close(end)
|
|
||||||
close(out)
|
close(out)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return parseDhcpConfig(end, out)
|
return parseDhcpConfig(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func compareSlice(a, b []string) bool {
|
func compareSlice(a, b []string) bool {
|
||||||
|
|
Loading…
Reference in New Issue