THRIFT-5583: Add skip_remote arg to go compiler

Client: go
diff --git a/CHANGES.md b/CHANGES.md
index 8481d11..9c81fad 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -5,6 +5,7 @@
 ### Go
 
 - [THRIFT-5539](https://issues.apache.org/jira/browse/THRIFT-5539) - `TDebugProtocol.DuplicateTo` is now deprecated, `TDuplicateToProtocol` has been provided as the replacement
+- [THRIFT-5583](https://issues.apache.org/jira/browse/THRIFT-5583) - Add `skip_remote` arg to compiler, which can be used to skip the generating of -remote folders for services
 
 ## 0.16.0
 
diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc
index 020297b..4833420 100644
--- a/compiler/cpp/src/thrift/generate/t_go_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc
@@ -83,6 +83,7 @@
     package_flag = "";
     read_write_private_ = false;
     ignore_initialisms_ = false;
+    skip_remote_ = false;
     for( iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) {
       if( iter->first.compare("package_prefix") == 0) {
         gen_package_prefix_ = (iter->second);
@@ -94,6 +95,8 @@
         read_write_private_ = true;
       } else if( iter->first.compare("ignore_initialisms") == 0) {
         ignore_initialisms_ =  true;
+      } else if( iter->first.compare("skip_remote") == 0) {
+        skip_remote_ =  true;
       } else {
         throw "unknown option go:" + iter->first;
       }
@@ -297,6 +300,7 @@
   std::string gen_thrift_import_;
   bool read_write_private_;
   bool ignore_initialisms_;
+  bool skip_remote_;
 
   /**
    * File streams
@@ -2015,7 +2019,9 @@
   generate_service_client(tservice);
   generate_service_server(tservice);
   generate_service_helpers(tservice);
-  generate_service_remote(tservice);
+  if(!skip_remote_) {
+    generate_service_remote(tservice);
+  }
   f_types_ << endl;
 }
 
@@ -4267,4 +4273,6 @@
                           "    ignore_initialisms\n"
                           "                     Disable automatic spelling correction of initialisms (e.g. \"URL\")\n" \
                           "    read_write_private\n"
-                          "                     Make read/write methods private, default is public Read/Write\n")
+                          "                     Make read/write methods private, default is public Read/Write\n"
+                          "    skip_remote\n"
+                          "                     Skip the generating of -remote folders for the client binaries for services\n")
diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am
index e1cf8cd..4392ebe 100644
--- a/lib/go/test/Makefile.am
+++ b/lib/go/test/Makefile.am
@@ -23,9 +23,13 @@
 GOBUILDEXTRA =
 endif
 
-THRIFTARGS = -out gopath/src/ --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/lib/go/test/gopath/src/$(COMPILER_EXTRAFLAG)
+THRIFT_GO_ARGS_BASE = thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/lib/go/test/gopath/src/
+
+THRIFTARGS = -out gopath/src/ --gen go:$(THRIFT_GO_ARGS_BASE)$(COMPILER_EXTRAFLAG)
 THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
 
+THRIFTARGS_SKIP_REMOTE = -out gopath/src/ --gen go:skip_remote,$(THRIFT_GO_ARGS_BASE)$(COMPILER_EXTRAFLAG)
+
 # Thrift for GO has problems with complex map keys: THRIFT-2063
 gopath: $(THRIFT) $(THRIFTTEST) \
 				IncludesTest.thrift \
@@ -91,7 +95,7 @@
 	$(THRIFT) $(THRIFTARGS) EqualsTest.thrift
 	$(THRIFT) $(THRIFTARGS) ConflictArgNamesTest.thrift
 	$(THRIFT) $(THRIFTARGS) -r ConstOptionalField.thrift
-	$(THRIFT) $(THRIFTARGS) ProcessorMiddlewareTest.thrift
+	$(THRIFT) $(THRIFTARGS_SKIP_REMOTE) ProcessorMiddlewareTest.thrift
 	ln -nfs ../../tests gopath/src/tests
 	cp -r ./dontexportrwtest gopath/src
 	touch gopath