From e77c50f0a19b8d5de63f0a604dcf70ab68994b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E7=94=B0=E3=80=80=E3=82=A2=E3=83=9D=E3=83=AD?= Date: Tue, 16 Oct 2018 17:22:14 -0700 Subject: [PATCH 1/3] Update reverseproxy.go Enhance EC solaris build --- src/net/http/httputil/reverseproxy.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go index f8b60b6d33..c4a35b5d6c 100644 --- a/src/net/http/httputil/reverseproxy.go +++ b/src/net/http/httputil/reverseproxy.go @@ -47,6 +47,18 @@ type ReverseProxy struct { // If nil, logging goes to os.Stderr via the log package's // standard logger. ErrorLog *log.Logger + + // ModifyResponse is an optional function that modifies the + // Response from the backend. It is called if the backend + // returns a response at all, with any HTTP status code. + // If the backend is unreachable, the optional ErrorHandler is + // called without any call to ModifyResponse. + // + // If ModifyResponse returns an error, ErrorHandler is called + // with its error value. If ErrorHandler is nil, its default + // implementation is used. + // This is to enhance EC Solaris SPARC64 plugin build so that it will modify the TLS response header. + ModifyResponse func(*http.Response) error // BufferPool optionally specifies a buffer pool to // get byte slices for use by io.CopyBuffer when @@ -215,6 +227,15 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) { for _, h := range hopHeaders { res.Header.Del(h) } + + // add to support EC Solaris build + if p.ModifyResponse != nil { + if err := p.ModifyResponse(res); err != nil { + res.Body.Close() + p.getErrorHandler()(rw, outreq, err) + return + } + } copyHeader(rw.Header(), res.Header) From 9406a2cc6871a25caac605da10e75bf7125816b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E7=94=B0=E3=80=80=E3=82=A2=E3=83=9D=E3=83=AD?= Date: Tue, 16 Oct 2018 17:36:41 -0700 Subject: [PATCH 2/3] Update reverseproxy.go --- src/net/http/httputil/reverseproxy.go | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go index c4a35b5d6c..a7e4aadf25 100644 --- a/src/net/http/httputil/reverseproxy.go +++ b/src/net/http/httputil/reverseproxy.go @@ -64,6 +64,14 @@ type ReverseProxy struct { // get byte slices for use by io.CopyBuffer when // copying HTTP response bodies. BufferPool BufferPool + + // ErrorHandler is an optional function that handles errors + // reaching the backend or errors from ModifyResponse. + // + // If nil, the default is to log the provided error and return + // a 502 Status Bad Gateway response. + // This is to support EC Solaris SPARC64 build + ErrorHandler func(http.ResponseWriter, *http.Request, error) } // A BufferPool is an interface for getting and returning temporary @@ -73,6 +81,27 @@ type BufferPool interface { Put([]byte) } +// Add default Error Handler to support EC Solaris SPARC64 build +func (p *ReverseProxy) defaultErrorHandler(rw http.ResponseWriter, req *http.Request, err error)\ + { + + p.logf("http: proxy error: %v", err) + + rw.WriteHeader(http.StatusBadGateway) + +} + + +// Add Error Handler to support EC Solaris SPARC64 build +func (p *ReverseProxy) getErrorHandler() func(http.ResponseWriter, *http.Request, error) { + if p.ErrorHandler != nil { + + return p.ErrorHandler + } + + return p.defaultErrorHandler +} + func singleJoiningSlash(a, b string) string { aslash := strings.HasSuffix(a, "/") bslash := strings.HasPrefix(b, "/") From e2a3d01030d6fc8b8998c1fc7066a7c674d08a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E7=94=B0=E3=80=80=E3=82=A2=E3=83=9D=E3=83=AD?= Date: Wed, 17 Oct 2018 14:19:16 -0700 Subject: [PATCH 3/3] Update build.go update git issue during the compiling --- src/cmd/dist/build.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index ba23bcafc4..a20d78a692 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -328,15 +328,20 @@ func findgoversion() string { // isGitRepo reports whether the working directory is inside a Git repository. func isGitRepo() bool { - // NB: simply checking the exit code of `git rev-parse --git-dir` would - // suffice here, but that requires deviating from the infrastructure - // provided by `run`. - gitDir := chomp(run(goroot, 0, "git", "rev-parse", "--git-dir")) - if !filepath.IsAbs(gitDir) { - gitDir = filepath.Join(goroot, gitDir) - } - fi, err := os.Stat(gitDir) - return err == nil && fi.IsDir() + p := ".git" + for { + fi, err := os.Stat(p) + + if os.IsNotExist(err) { + p = filepath.Join("..", p) + continue + } + + if err != nil || !fi.IsDir() { + return false + } + return true + } } /*