我是 golang 和编程的新手。
我编写了一个小程序,将匹配正则表达式的文件从一个目录移动到另一个目录。
该程序在 ubuntu 16.04 和 Centos 6.8(最终版)上成功运行
在某台 Centos 机器上(我不知道那台机器的确切版本。我知道它是 6.? 并且低于 6.8),我得到:
分段错误(核心转储)
我的研究表明,当操作系统不允许我访问内存时会发生此错误。
有人可以告诉我代码中哪里出错了。如果您看到任何不良做法,也请指出。
package main
import (
"flag"
"fmt"
"log"
"os"
"regexp"
"strings"
)
func main() {
batch := flag.Int("batch", 0, "the amount of files to be processed")
pattern := flag.String("pattern", "", "string pattern to be matched")
dir := flag.Int("dir", 0, "key from strings.Split(pattern, '')")
confirm := flag.String("move", "no", "flags if program should move files")
flag.Parse()
d, err := os.Open(".")
if err != nil …Run Code Online (Sandbox Code Playgroud) protoc --gogofaster_out=. image.proto
我收到此错误消息
/home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto:找不到文件。
image.proto:导入“/home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto”未找到或有错误。
该文件肯定在那里。我可以从错误中报告的路径到达它。
我的原型文件如下所示:
package image;
import "/home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto";
message Frame {
required bool fragment = 1;
required int32 fragmentID = 2;
required bool lastFragment = 3;
required bytes data = 4;
}
Run Code Online (Sandbox Code Playgroud)
我Makefile在 proto 文件所在的目录中有一个。看起来像这样:
regenerate:
--proto_path=../../github.com/gogo/protobuf/gogoproto:../../github.com/gogo/protobuf/protobuf/google/protobuf:. --gogofaster_out=. *.proto
Run Code Online (Sandbox Code Playgroud)
我该如何解决路径错误?
我一直在尝试 v4l2,最终成功连接到笔记本电脑的摄像头并将其设置为流式传输。
目前我将帧保存为等1.jpg。2.jpg
从基本层面考虑,我需要一个存储这些 jpeg 的容器,然后视频播放器按顺序运行容器内容并获得视频。
我假设视频格式将成为我的容器。
我如何创建并写入一个?