VOL-1691 Fix openolt adapter getting stuck while registartion with core

Change-Id: Ide8131f325bc15f1b909e14d7af6ee9bcd6b3b5b
diff --git a/vendor/golang.org/x/text/internal/gen/code.go b/vendor/golang.org/x/text/internal/gen/code.go
index 0389509..75435c9 100644
--- a/vendor/golang.org/x/text/internal/gen/code.go
+++ b/vendor/golang.org/x/text/internal/gen/code.go
@@ -48,7 +48,7 @@
 }
 
 // WriteGoFile appends the buffer with the total size of all created structures
-// and writes it as a Go file to the the given file with the given package name.
+// and writes it as a Go file to the given file with the given package name.
 func (w *CodeWriter) WriteGoFile(filename, pkg string) {
 	f, err := os.Create(filename)
 	if err != nil {
@@ -61,12 +61,14 @@
 }
 
 // WriteVersionedGoFile appends the buffer with the total size of all created
-// structures and writes it as a Go file to the the given file with the given
+// structures and writes it as a Go file to the given file with the given
 // package name and build tags for the current Unicode version,
 func (w *CodeWriter) WriteVersionedGoFile(filename, pkg string) {
 	tags := buildTags()
 	if tags != "" {
-		filename = insertVersion(filename, UnicodeVersion())
+		pattern := fileToPattern(filename)
+		updateBuildTags(pattern)
+		filename = fmt.Sprintf(pattern, UnicodeVersion())
 	}
 	f, err := os.Create(filename)
 	if err != nil {
@@ -79,10 +81,12 @@
 }
 
 // WriteGo appends the buffer with the total size of all created structures and
-// writes it as a Go file to the the given writer with the given package name.
+// writes it as a Go file to the given writer with the given package name.
 func (w *CodeWriter) WriteGo(out io.Writer, pkg, tags string) (n int, err error) {
 	sz := w.Size
-	w.WriteComment("Total table size %d bytes (%dKiB); checksum: %X\n", sz, sz/1024, w.Hash.Sum32())
+	if sz > 0 {
+		w.WriteComment("Total table size %d bytes (%dKiB); checksum: %X\n", sz, sz/1024, w.Hash.Sum32())
+	}
 	defer w.buf.Reset()
 	return WriteGo(out, pkg, tags, w.buf.Bytes())
 }
@@ -199,7 +203,6 @@
 
 // WriteString writes a string literal.
 func (w *CodeWriter) WriteString(s string) {
-	s = strings.Replace(s, `\`, `\\`, -1)
 	io.WriteString(w.Hash, s) // content hash
 	w.Size += len(s)
 
@@ -250,6 +253,9 @@
 				out = fmt.Sprintf("\\U%08x", r)
 			}
 			chars = len(out)
+		} else if r == '\\' {
+			out = "\\" + string(r)
+			chars = 2
 		}
 		if n -= chars; n < 0 {
 			nLines++
diff --git a/vendor/golang.org/x/text/internal/gen/gen.go b/vendor/golang.org/x/text/internal/gen/gen.go
index 4c3f760..cc6510f 100644
--- a/vendor/golang.org/x/text/internal/gen/gen.go
+++ b/vendor/golang.org/x/text/internal/gen/gen.go
@@ -7,7 +7,7 @@
 //
 // This package defines command line flags that are common to most generation
 // tools. The flags allow for specifying specific Unicode and CLDR versions
-// in the public Unicode data repository (http://www.unicode.org/Public).
+// in the public Unicode data repository (https://www.unicode.org/Public).
 //
 // A local Unicode data mirror can be set through the flag -local or the
 // environment variable UNICODE_DIR. The former takes precedence. The local
@@ -31,6 +31,7 @@
 	"os"
 	"path"
 	"path/filepath"
+	"regexp"
 	"strings"
 	"sync"
 	"unicode"
@@ -40,7 +41,7 @@
 
 var (
 	url = flag.String("url",
-		"http://www.unicode.org/Public",
+		"https://www.unicode.org/Public",
 		"URL of Unicode database directory")
 	iana = flag.String("iana",
 		"http://www.iana.org",
@@ -83,25 +84,21 @@
 }
 
 var tags = []struct{ version, buildTags string }{
-	{"10.0.0", "go1.10"},
-	{"", "!go1.10"},
+	{"9.0.0", "!go1.10"},
+	{"10.0.0", "go1.10,!go1.13"},
+	{"11.0.0", "go1.13"},
 }
 
 // buildTags reports the build tags used for the current Unicode version.
 func buildTags() string {
 	v := UnicodeVersion()
-	for _, x := range tags {
-		// We should do a numeric comparison, but including the collate package
-		// would create an import cycle. We approximate it by assuming that
-		// longer version strings are later.
-		if len(x.version) <= len(v) {
-			return x.buildTags
-		}
-		if len(x.version) == len(v) && x.version <= v {
-			return x.buildTags
+	for _, e := range tags {
+		if e.version == v {
+			return e.buildTags
 		}
 	}
-	return tags[0].buildTags
+	log.Fatalf("Unknown build tags for Unicode version %q.", v)
+	return ""
 }
 
 // IsLocal reports whether data files are available locally.
@@ -269,12 +266,29 @@
 	}
 }
 
-func insertVersion(filename, version string) string {
+func fileToPattern(filename string) string {
 	suffix := ".go"
 	if strings.HasSuffix(filename, "_test.go") {
 		suffix = "_test.go"
 	}
-	return fmt.Sprint(filename[:len(filename)-len(suffix)], version, suffix)
+	prefix := filename[:len(filename)-len(suffix)]
+	return fmt.Sprint(prefix, "%s", suffix)
+}
+
+func updateBuildTags(pattern string) {
+	for _, t := range tags {
+		oldFile := fmt.Sprintf(pattern, t.version)
+		b, err := ioutil.ReadFile(oldFile)
+		if err != nil {
+			continue
+		}
+		build := fmt.Sprintf("// +build %s", t.buildTags)
+		b = regexp.MustCompile(`// \+build .*`).ReplaceAll(b, []byte(build))
+		err = ioutil.WriteFile(oldFile, b, 0644)
+		if err != nil {
+			log.Fatal(err)
+		}
+	}
 }
 
 // WriteVersionedGoFile prepends a standard file comment, adds build tags to
@@ -282,16 +296,16 @@
 // the given bytes, applies gofmt, and writes them to a file with the given
 // name. It will call log.Fatal if there are any errors.
 func WriteVersionedGoFile(filename, pkg string, b []byte) {
-	tags := buildTags()
-	if tags != "" {
-		filename = insertVersion(filename, UnicodeVersion())
-	}
+	pattern := fileToPattern(filename)
+	updateBuildTags(pattern)
+	filename = fmt.Sprintf(pattern, UnicodeVersion())
+
 	w, err := os.Create(filename)
 	if err != nil {
 		log.Fatalf("Could not create file %s: %v", filename, err)
 	}
 	defer w.Close()
-	if _, err = WriteGo(w, pkg, tags, b); err != nil {
+	if _, err = WriteGo(w, pkg, buildTags(), b); err != nil {
 		log.Fatalf("Error writing file %s: %v", filename, err)
 	}
 }