gitee.com/quant1x/engine@v1.8.4/utils/template_test.go (about) 1 package utils 2 3 import ( 4 "fmt" 5 "gitee.com/quant1x/engine/cache" 6 "strings" 7 "testing" 8 ) 9 10 var propertyList = `<?xml version="1.0" encoding="UTF-8"?> 11 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 12 <plist version="1.0"> 13 <dict> 14 <key>KeepAlive</key> 15 <true/> 16 <key>Label</key> 17 <string>{{.Name}}</string> 18 <key>ProgramArguments</key> 19 <array> 20 <string>{{.Path}}</string> 21 <string>daemon</string> 22 </array> 23 <key>RunAtLoad</key> 24 <true/> 25 <key>WorkingDirectory</key> 26 <string>${ROOT_PATH}</string> 27 <key>StandardErrorPath</key> 28 <string>${LOG_PATH}/{{.Name}}.err</string> 29 <key>StandardOutPath</key> 30 <string>${LOG_PATH}/{{.Name}}.log</string> 31 </dict> 32 </plist> 33 ` 34 35 func TestTemplate(t *testing.T) { 36 replacer := strings.NewReplacer("${ROOT_PATH}", cache.GetRootPath(), "${LOG_PATH}", cache.GetLoggerPath()) 37 //v := strings.ReplaceAll(propertyList, "${PATH}", cache.GetRootPath()) 38 v := replacer.Replace(propertyList) 39 fmt.Println(v) 40 }