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