ExtractAnnotations extracts annotations from comments prefixed with '@', and optionally a value after a ':'. Examples: "-- @materialize" and "-- @materialize: true".
(sql string)
| 9 | // ExtractAnnotations extracts annotations from comments prefixed with '@', and optionally a value after a ':'. |
| 10 | // Examples: "-- @materialize" and "-- @materialize: true". |
| 11 | func ExtractAnnotations(sql string) map[string]string { |
| 12 | annotations := map[string]string{} |
| 13 | subMatches := annotationsRegex.FindAllStringSubmatch(sql, -1) |
| 14 | for _, subMatch := range subMatches { |
| 15 | k := subMatch[1] |
| 16 | v := "" |
| 17 | if len(subMatch) > 2 { |
| 18 | v = subMatch[2] |
| 19 | } |
| 20 | annotations[k] = v |
| 21 | } |
| 22 | return annotations |
| 23 | } |
no outgoing calls