我正在尝试提取内部的任何数据${}.
例如,从该字符串中提取的数据应该是abc.
git commit -m '${abc}'
Run Code Online (Sandbox Code Playgroud)
这是实际的代码:
re := regexp.MustCompile("${*}")
match := re.FindStringSubmatch(command)
Run Code Online (Sandbox Code Playgroud)
但这不起作用,任何想法?
read, err := ioutil.ReadFile(path)
if err != nil {
return err
}
if strings.Contains(string(read), "STRING") {
// display line number?
// what if many occurrences of the string
// how to display for each the line number?
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试搜索特定字符串的文件并显示字符串所在的行号.
我正在尝试使用go执行命令.
executableCommand := strings.Split("git commit -m 'hello world'", " ")
executeCommand(executableCommand[0], executableCommand[1:]...)
cmd := exec.Command(command, args...)
Run Code Online (Sandbox Code Playgroud)
但这就是我得到的
error: pathspec 'world"' did not match any file(s) known to git.
exit status 1
Run Code Online (Sandbox Code Playgroud)
这是因为-m获得'hello的,而不是'hello world'因为在命令行中使用分裂" ".
有什么想让它发挥作用吗?
我有一个模型Task,其范围名为done. ATask属于 aProject且属于 a User。
我需要按用户已完成的项目来过滤用户task。
simple_form_for @q do |form|
form.input :tasks_done_project_id, collection: Project.ordered
Run Code Online (Sandbox Code Playgroud)
但使用“_done”不起作用。
我想到了一个掠夺者:
ransacker :done do |parent|
parent.done.table[:id]
end
Run Code Online (Sandbox Code Playgroud)
但也不起作用。任何想法?