Go 1.5+ : Error - imports runtime: C source files not allowed when not using cgo or SWIG

后端 未结 4 834
情书的邮戳
情书的邮戳 2021-02-07 03:07

My program was building perfectly with go 1.4.2. After installing go 1.5, I am getting following error.

imports runtime: C source files not allowed when n

4条回答
  •  深忆病人
    2021-02-07 03:53

    Remove Old 1.4.x go installation and then install go 1.5.

    I faced the same problem after installing go 1.5. The issue is that I installed go 1.5 at the same place of 1.4.2. Go 1.5 does not use C anymore and if old C installation files are present it throws the error as you are shown.

    if you want the old installation to be present as well then install 1.5 to some other location and set GOROOT to that location.

    Hope it helps.

    Edit 1: For Linux Users:

    if you downloaded go1.5*.tar.gz then you did this:

    tar -C /usr/local/ -xvf go1.5.linux-amd64.tar.gz

    Your old folder C files are not deleted, so the correct process is:

    First: You should delete you old go folder.

    sudo rm -rf /usr/local/go/

    Second: Then run

    tar -C /usr/local/ -xvf go1.5.x.linux-amd64.tar.gz

提交回复
热议问题