Bootstrap

使用Goland对6.5840项目进行go build出现异常

使用Goland对6.5840项目进行go build出现异常

  • Lab地址: https://pdos.csail.mit.edu/6.824/labs/lab-mr.html
  • 项目地址: git://g.csail.mit.edu/6.5840-golabs-2024 6.5840
  • 运行环境: mac系统 goland
git clone git://g.csail.mit.edu/6.5840-golabs-2024 6.5840
cd 6.5840/src/main
go build -buildmode=plugin ../mrapps/wc.go # 构建 wc.so

配置Goland

  • 选择上方 Edit Configuration 配置 Run/Debug Configurations
    • 选择: go build
    • Name: mrsequential
    • Files: src/main/mrsequential.go
    • 勾选 Run after build
    • Working Directory: 6.5840/src/main
    • Program arguments: wc.so pg-*.txt
      在这里插入图片描述
  • 配置参数 wc.so pg-*.txt 的原因是 mrsequential.go 会接收 so 动态链接库, 而 pg-*.txt 作为文件传入
    在这里插入图片描述
  • 当配置完选择运行时出现报错: cannot open pg-*.txt
    • 一开始怀疑mac版本过低, 但是后面找另一台电脑也同样报错
      在这里插入图片描述
  • 后面发现是因为 go build 无法接受通配符参数 pg-*.txt 导致 (只能用 go run 接收通配符参数)
    在这里插入图片描述
  • 因此写死文件名即解决
    在这里插入图片描述
;