mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-13 03:56:39 +00:00
c28f7cb29f
Initial part of #435
36 lines
563 B
Go
36 lines
563 B
Go
package job
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/golangci/dupl/syntax"
|
|
"github.com/golangci/dupl/syntax/golang"
|
|
)
|
|
|
|
func Parse(fchan chan string) chan []*syntax.Node {
|
|
|
|
// parse AST
|
|
achan := make(chan *syntax.Node)
|
|
go func() {
|
|
for file := range fchan {
|
|
ast, err := golang.Parse(file)
|
|
if err != nil {
|
|
log.Println(err)
|
|
continue
|
|
}
|
|
achan <- ast
|
|
}
|
|
close(achan)
|
|
}()
|
|
|
|
// serialize
|
|
schan := make(chan []*syntax.Node)
|
|
go func() {
|
|
for ast := range achan {
|
|
seq := syntax.Serialize(ast)
|
|
schan <- seq
|
|
}
|
|
close(schan)
|
|
}()
|
|
return schan
|
|
}
|