@@ -72,11 +72,14 @@ func addMeta(tagMetas TagMetas, meta *Meta) {
7272
7373func findTag (content []byte , r * regexp.Regexp ) string {
7474 res := r .FindSubmatch (content )
75+ if len (res ) < 2 {
76+ return ""
77+ }
7578 return string (res [1 ])
7679}
7780
7881func findMeta (content []byte , fp string ) * Meta {
79- draft := findTag (content , draftRegex ) == "true"
82+ draft := findTag (content , draftRegex ) == "" || findTag ( content , draftRegex ) == " true"
8083 if draft {
8184 return nil
8285 }
@@ -104,8 +107,16 @@ func fileExists(path string) bool {
104107 return ! os .IsNotExist (err )
105108}
106109
110+ func isDirectory (path string ) (bool , error ) {
111+ fileInfo , err := os .Stat (path )
112+ if err != nil {
113+ return false , err
114+ }
115+ return fileInfo .IsDir (), err
116+ }
117+
107118func Run () {
108- files , err := doublestar .Glob ("./solve/**/**.go " )
119+ files , err := doublestar .Glob ("./solve/**/*" )
109120 if err != nil {
110121 log .Fatal (err )
111122 }
@@ -114,7 +125,11 @@ func Run() {
114125 wg := sync.WaitGroup {}
115126 var lock sync.Mutex
116127 for _ , fp := range files {
117- if strings .HasSuffix (fp , "test.go" ) || ! strings .HasSuffix (fp , ".go" ) {
128+ if isFolder , _ := isDirectory (fp ); isFolder {
129+ continue
130+ }
131+
132+ if strings .HasSuffix (fp , ".md" ) {
118133 continue
119134 }
120135 wg .Add (1 )
@@ -125,9 +140,11 @@ func Run() {
125140 log .Fatal (err )
126141 }
127142 meta := findMeta (content , fp )
128- lock .Lock ()
129- addMeta (tagMetas , meta )
130- lock .Unlock ()
143+ if meta != nil {
144+ lock .Lock ()
145+ addMeta (tagMetas , meta )
146+ lock .Unlock ()
147+ }
131148 wg .Done ()
132149 }()
133150 }
0 commit comments