golangconfig: Add support for multiple paths in GOPATH

The path checker now will properly check GOPATH settings that
contain multiple paths.

Change-Id: I1e750d6d44051ba50b5230c30ce2779ddb82cefa
Reviewed-on: https://go-review.googlesource.com/16251
Reviewed-by: Jason Buberel <jbuberel@google.com>
diff --git a/all/golangconfig.py b/all/golangconfig.py
index d73d72c..cf57e0f 100644
--- a/all/golangconfig.py
+++ b/all/golangconfig.py
@@ -289,18 +289,39 @@
     # user experience, especially around debugging
     is_str = isinstance(setting, str_cls)
     if is_str:
-        if os.path.exists(setting):
-            return (setting, source)
 
-        if debug_enabled():
-            print(
-                'golangconfig: the value for %s from %s - "%s" - does not exist on the filesystem' %
-                (
-                    setting_name,
-                    source,
-                    setting
-                )
+        multiple_values = False
+
+        if setting_name == 'GOROOT':
+            if os.path.exists(setting):
+                return (setting, source)
+
+        if setting_name == 'GOPATH':
+            values = setting.split(os.pathsep)
+            multiple_values = len(values) > 1
+            missing = False
+
+            for value in values:
+                if not os.path.exists(value):
+                    missing = True
+                    break
+
+            if not missing:
+                return (setting, source)
+
+        if multiple_values:
+            value_desc = "one of the values"
+        else:
+            value_desc = "the value"
+        print(
+            'golangconfig: %s for %s from %s - "%s" - does not exist on the filesystem' %
+            (
+                value_desc,
+                setting_name,
+                source,
+                setting
             )
+        )
 
     elif debug_enabled():
         _debug_unicode_string(setting_name, setting, source)
diff --git a/dev/tests.py b/dev/tests.py
index 0e6e3aa..4d3cab4 100644
--- a/dev/tests.py
+++ b/dev/tests.py
@@ -539,6 +539,34 @@
             )
             self.assertTrue('does not exist on the filesystem' in sys.stdout.getvalue())
 
+    def test_setting_value_multiple_gopath_one_not_existing(self):
+        shell = '/bin/bash'
+        env = {
+            'GOPATH': '{tempdir}bin%s{tempdir}usr/bin' % os.pathsep
+        }
+        with GolangConfigMock(shell, env, None, None, {'debug': True}) as mock_context:
+            mock_context.replace_tempdir_env()
+            mock_context.make_dirs(['usr/bin'])
+            self.assertEquals(
+                (None, None),
+                golangconfig.setting_value('GOPATH', mock_context.view, mock_context.window)
+            )
+            self.assertTrue('one of the values for GOPATH' in sys.stdout.getvalue())
+
+    def test_setting_value_multiple_gopath(self):
+        shell = '/bin/bash'
+        env = {
+            'GOPATH': '{tempdir}bin%s{tempdir}usr/bin' % os.pathsep
+        }
+        with GolangConfigMock(shell, env, None, None, {'debug': True}) as mock_context:
+            mock_context.replace_tempdir_env()
+            mock_context.make_dirs(['bin', 'usr/bin'])
+            self.assertEquals(
+                (env['GOPATH'], shell),
+                golangconfig.setting_value('GOPATH', mock_context.view, mock_context.window)
+            )
+            self.assertEqual('', sys.stdout.getvalue())
+
     def test_setting_value_gopath_not_string(self):
         shell = '/bin/bash'
         env = {