mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 21:40:35 +07:00
gracefull shutdown for unresolvable errors
This commit is contained in:
@@ -1,32 +1,36 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
"strings"
|
||||
"bufio"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetStructList(filePath string) ([]string) {
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer file.Close()
|
||||
var structNames []string
|
||||
s := bufio.NewScanner(file)
|
||||
for s.Scan() {
|
||||
line := s.Text()
|
||||
if strings.Contains(line, "type ") && strings.Contains(line, " struct") {
|
||||
start := strings.Index(line, "type ") + 5
|
||||
end := strings.Index(line, " struct")
|
||||
name := strings.TrimSpace(line[start:end])
|
||||
if name != "" {
|
||||
structNames = append(structNames, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := s.Err(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return structNames
|
||||
}
|
||||
func GetStructList(filePath string) []string {
|
||||
file, err := os.Open(filePath)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to open a file: %s", err)
|
||||
}
|
||||
|
||||
var structNames []string
|
||||
s := bufio.NewScanner(file)
|
||||
for s.Scan() {
|
||||
line := s.Text()
|
||||
if strings.Contains(line, "type ") && strings.Contains(line, " struct") {
|
||||
start := strings.Index(line, "type ") + 5
|
||||
end := strings.Index(line, " struct")
|
||||
name := strings.TrimSpace(line[start:end])
|
||||
if name != "" {
|
||||
structNames = append(structNames, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if s.Err() != nil {
|
||||
log.Fatalf("")
|
||||
}
|
||||
|
||||
return structNames
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user