/
dimamir
/
rill
Обзор
Документация
Войти
/
dimamir
/
rill
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
runtime/pkg/sqlparse/annotations.go
23 строки
635 B
Benjamin Egelund-Müller
Async reconcile: resource definitions and code file parser (#2761)
18 июл 2023, 16:39
Не верифицирован
18 июл 2023, 16:39
c8509a4
Код
Авторство
О чём код?
package sqlparse import ( "regexp" ) var annotationsRegex = regexp.MustCompile(`(?m)^--[ \t]*@([a-zA-Z0-9_\-.]*)[ \t]*(?::[ \t]*(.*?))?\s*$`) // ExtractAnnotations extracts annotations from comments prefixed with '@', and optionally a value after a ':'. // Examples: "-- @materialize" and "-- @materialize: true". func ExtractAnnotations(sql string) map[string]string { annotations := map[string]string{} subMatches := annotationsRegex.FindAllStringSubmatch(sql, -1) for _, subMatch := range subMatches { k := subMatch[1] v := "" if len(subMatch) > 2 { v = subMatch[2] } annotations[k] = v } return annotations }