#6 Don't swallow the output of go get when it fails.
Merged 4 years ago by eclipseo. Opened 4 years ago by qulogic.
GoSIG/ qulogic/go2rpm debug-go-get  into  master

file modified
+10 -3
@@ -257,10 +257,17 @@ 

                                  stderr=subprocess.STDOUT)

      except subprocess.CalledProcessError as err:

          if b'no Go files in' in err.stdout:

-             subprocess.check_output(['go', 'get', '-d', goipath + '/...'],

-                                     stderr=subprocess.STDOUT)

+             try:

+                 subprocess.check_output(['go', 'get', '-d', goipath + '/...'],

+                                         stderr=subprocess.STDOUT)

+             except subprocess.CalledProcessError as err:

+                 print(f"ERROR: Unable to 'go get {goipath}':")

+                 print(err.stdout.decode())

+                 sys.exit(1)

          else:

-             raise

+             print(f"ERROR: Unable to 'go get {goipath}':")

+             print(err.stdout.decode())

+             sys.exit(1)

      repo = git.Repo(os.path.join(GIT_CACHEDIR, *get_repo_host(goipath)))

      repo.git.checkout("master")

      repo.head.reference = repo.heads.master

check_output consumes the output, so the user will just see an exception, but not the real problem from go get.

Pull-Request has been merged by eclipseo

4 years ago
Metadata