Skip to content

Commit 1c6a410

Browse files
committed
fix: fix crash issues for golang
1 parent e103097 commit 1c6a410

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ allprojects {
2525
apply(plugin = "java")
2626

2727
group = "com.phodal.chapi"
28-
version = "2.0.0-beta.7"
28+
version = "2.0.0-beta.8"
2929
description =
3030
"Chapi is A common language meta information convertor, convert different languages to same meta-data model"
3131

chapi-ast-go/src/test/kotlin/chapi/ast/goast/GoAnalyserTest.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,17 @@ func main() {
4242
@Test
4343
@Disabled
4444
fun analysisByDir() {
45-
val dir = "/iam"
45+
val dir = "/Users/phodal/test/iam"
4646
val codeContainer = GoAnalyser().analysisByDir(dir)
47-
println(codeContainer)
47+
// write to file
48+
val json = Json.encodeToString(codeContainer)
49+
File("iam.json").writeText(json)
4850
}
4951
}
5052

5153
private fun GoAnalyser.analysisByDir(dir: String): List<CodeContainer> {
52-
val codeContainers = mutableListOf<CodeContainer>()
5354
val files = File(dir).walkTopDown().filter { it.isFile && it.extension == "go" }.toList()
54-
files.forEach {
55-
println(it.absolutePath)
56-
val codeContainer = analysis(it.readText(), it.name)
57-
codeContainers.add(codeContainer)
58-
}
59-
return codeContainers
55+
return files.map {
56+
analysis(it.readText(), it.name)
57+
}.toList()
6058
}

0 commit comments

Comments
 (0)