A strange problem with the Golang compilation process

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

The following error occurred while compiling the Golang program:

Cannot create <nil>/go.o:no such file or directory
Make: * * * [BUILD/MDS] Error 2

Cause of error

Go build will create temporary files, guess the temporary directory related problems, view the next source code

[SRC/CMD/LDLIB.C 652-675]static voidhostlinksetup (void) {char *p;if (linkmode! = linkexternal) return;//Create Temporary directory and arrange cleanupif (tmpdir = = nil) {Tmpdir = Mktempdir (); atexit (rmtemp);} Change we output to temporary object FileClose (cout);p = Smprint ("%s/go.o", tmpdir); cout = Create (P, 1, 0775); if (cout < 0) {diag ("Cannot create%s:%r", p); Errorexit ();} Free (p);}
As you can see, this is the Tmpdir directory, so continue to find

[Src/lib9/tempdir_unix.c 13-25]char*mktempdir (void) {char *tmp, *p;tmp = getenv ("TMPDIR"); if (tmp = = Nil | | strlen (TMP) = = 0) tmp = "/var/tmp";p = Smprint ("%s/go-link-xxxxxx", TMP), if (Mkdtemp (p) = = nil) return Nil;return p;}
Then found that the temporary directory is/var/tmp, looked at this directory, found that space is incredibly full, embarrassed

df-lh/var/tmp/
Filesystem Size used Avail use% mounted on
/dev/sda6 16G 16G 0 100%/var

Workaround:

1. Release part of the temporary directory space;

2. export tmpdir=/tmp, set other directory as temp directory

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.