Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6a309cd

Browse files
committed
feat: add basic xml parser
1 parent3acfea3 commit6a309cd

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

‎go.mod‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ require (
2525
github.com/yudai/ppv2.0.1+incompatible// indirect
2626
golang.org/x/expv0.0.0-20191224044220-1fea468a75e9// indirect
2727
gonum.org/v1/gonumv0.6.2
28+
gopkg.in/yaml.v2v2.3.0
2829
)

‎go.sum‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,5 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
161161
gopkg.in/yaml.v2v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
162162
gopkg.in/yaml.v2v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
163163
gopkg.in/yaml.v2v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
164+
gopkg.in/yaml.v2v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
164165
rsc.io/pdfv0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

‎pkg/domain/cloc/cloc_summary.go‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package cloc
2+
3+
// LanguageSummary to generate output like cloc
4+
typeLanguageSummaryClocstruct {
5+
Namestring`yaml:"name"`
6+
Codeint64`yaml:"code"`
7+
Commentint64`yaml:"comment"`
8+
Blankint64`yaml:"blank"`
9+
Countint64`yaml:"nFiles"`
10+
}
11+
12+
typeSummaryStructstruct {
13+
Codeint64`yaml:"code"`
14+
Commentint64`yaml:"comment"`
15+
Blankint64`yaml:"blank"`
16+
Countint64`yaml:"nFiles"`
17+
}
18+
19+
typeHeaderStructstruct {
20+
Urlstring`yaml:"url"`
21+
Versionstring`yaml:"version"`
22+
ElapsedSecondsfloat64`yaml:"elapsed_seconds"`
23+
NFilesint64`yaml:"n_files"`
24+
NLinesint64`yaml:"n_lines"`
25+
FilesPerSecondfloat64`yaml:"files_per_second"`
26+
LinesPerSecondfloat64`yaml:"lines_per_second"`
27+
}
28+
29+
typeLanguageReportStartstruct {
30+
HeaderHeaderStruct
31+
}
32+
33+
typeLanguageReportEndstruct {
34+
SumSummaryStruct`yaml:"SUM"`
35+
}
36+
37+
typeClocSummarystruct {
38+
HeaderHeaderStruct
39+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package cloc
2+
3+
4+
import (
5+
"fmt"
6+
."github.com/onsi/gomega"
7+
"gopkg.in/yaml.v2"
8+
"log"
9+
"testing"
10+
)
11+
12+
funcTest_Yaml_Parse_Model(t*testing.T) {
13+
t.Parallel()
14+
g:=NewGomegaWithT(t)
15+
16+
17+
vardata=`
18+
header:
19+
url: https://github.com/boyter/scc/
20+
version: 2.13.0
21+
elapsed_seconds: 0.006
22+
n_files: 25
23+
n_lines: 4045
24+
files_per_second: 4166.666666666667
25+
lines_per_second: 674166.6666666666
26+
27+
`
28+
29+
varheader=LanguageReportStart{}
30+
err:=yaml.Unmarshal([]byte(data),&header)
31+
iferr!=nil {
32+
log.Fatalf("error: %v",header)
33+
}
34+
35+
g.Expect(header.Header.Version).To(Equal("2.13.0"))
36+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp