环境配置

1 go下载安装go

  • 我做的是6.5840 - Spring 2025

  • 我使用的ubuntu版本如下:

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.1 LTS
Release:        24.04
Codename:       noble
  • go版本:
go version
go version go1.23.5 linux/amd64
  • 我使用的是Ubuntu + wsl + vscode(难受的一点就是,因为项目本身代码风格问题, 安装一些go的语法检查工具后, 就爆红了,虽然不影响运行,但是看着很难受,哈哈哈, 想了很久也没解决, 硬着头皮做了, 如果有大佬解决了,请踢我一下,向您学习)

go环境配置

设置环境变量:

// 在~/.bashrc最后添加:
export GOROOT=/usr/local/go   // root安装路径
export PATH=$PATH:$GOROOT/bin    // root工具所在路径
#export GOPATH=$HOME/go   // 项目代码我放在了/root/go/src/下


export CGO_ENABLED=1  // Go插件功能(-buildmode=plugin)​​必须​​启用CGO
export GOPROXY=https://goproxy.cn

// 再执行: source ~/.bashrc

2 拉取代码

Fetch the initial lab software with git (a version control system). To learn more about git, look at the Pro Git book or the git user's manual.

$ git clone git://g.csail.mit.edu/6.824-golabs-2022 6.824
$ cd 6.824
$ ls
Makefile src
$

We supply you with a simple sequential mapreduce implementation in src/main/mrsequential.go. It runs the maps and reduces one at a time, in a single process. We also provide you with a couple of MapReduce applications: word-count in mrapps/wc.go, and a text indexer in mrapps/indexer.go. You can run word count sequentially as follows:

$ cd ~/6.824
$ cd src/main
$ go build -race -buildmode=plugin ../mrapps/wc.go
$ rm mr-out*
$ go run -race mrsequential.go wc.so pg*.txt
$ more mr-out-0
A 509
ABOUT 2
ACT 8
...

只要样例结果一样就行

posted @ 2025-08-03 18:27  msnthh  阅读(0)  评论(0)    收藏  举报