Setup the MOAC dev env - coolcat2012/MoacDoc GitHub Wiki

Create User/yuechaoma/go

下载vscode

https://code.visualstudio.com/download

Install the vscode from download folder, then prompt to install git

download the git from the prompt link and install from download folder

or open the terminal to run git, if it does not exist it will prompt for downloading #git shows the helping now!!

下载安装vs go extension

https://marketplace.visualstudio.com/items?itemName=lukehoban.Go

goto the vscode left panel last item extension to search "go" and install all the go extensions such as go themes and go test outline etc

重启Vs (go the right-up coner search vscode to open, if fail then go to download folder to click open)

Install go binary

$ cd
$ vi .bash_profile

export GOROOT=/usr/local/go
export GOPATH=/Users/yuechaoma/go
export PATH=$PATH:/usr/local/go/bin/:$GOPATH/bin/

alias ll='ls -lGaf'

close the terminal and reopen termimal and try
#echo $GOROOT
you should see the content

make this folder /Users/yuechaoma/go/src/github.com/innowells

https://github.com/innowells/moac-scs/tree/scs-shanghai-l

Git clone the moac code

cd /Users/yuechaoma/go/src/github.com/innowells
git clone https://github.com/innowells/moac-scs.git
git clone https://github.com/innowells/moac-lib.git
git clone https://github.com/innowells/moac-vnode.git

do these for these folders

#git checkout scs-shanghai-l
#git checkout moac-shanghai-l
#git checkout vnode-shanghai-l

=====================

**compile code command line **

=====================

command line compile the SCS

cd /Users/yuechaoma/go/src/github.com/innowells/moac-scs
#./install_pkg.sh
#make

same thing for moac-vnode, but

#./install_pkg.sh
#make moac

vnode has error, need to install xcode first (25 minutes)

Install XCode and command line tools.
Install xCode from Apple App Store and run for first time and close out after it finishes setting up.
Open up Terminal and enter: xcode-select --install

still has the error: vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go:51:216: cannot use nil as type _Ctype_CFAllocatorRef in argument to func literal

Run this to download the govendor and the command will also generate the binary
go get -u github.com/kardianos/govendor

#cd /Users/yuechaoma/go/src/github.com/innowells/moac-vnode
update the /Users/yuechaoma/go/src/github.com/innowells/moac-vnode/vendor/vendor.json the rjeczalik version
note: the 4 lines are needed to be updated, copy from go-ethereum vendor.json
#govendor init
#govendor fetch github.com/rjeczalik/notify
#make moac

=====================

compile code in the vscode

=====================

add the configuration, node.js, replace all the content with following:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Test",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${workspaceRoot}/scsserver/main.go",
            "env": {
                "GOPATH": "/Users/yuechaoma/go",
                "GOROOT": "/usr/local/go"
            },
            "args": [],
            "showLog": true
        }
    ]
}
  • go terminal within the vscode,

  • vi the install_pkg.sh

  • copy all the go get lines and paste to run all

  • then start debug ok

  • in case of error of missing delve, do following to build the dlv debugger binary into $GOPATH/bin

go get github.com/derekparker/delve/cmd/dlv
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Test",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${workspaceRoot}/cmd/moac/main.go",
            "env": {
                "GOPATH": "/Users/yuechaoma/go",
                "GOROOT": "/usr/local/go"
            },
            "args": [],
            "showLog": true
        }
    ]
}