encoding/gocode: add Go code generator

Also:
- add gocodec used by generator
- added ability to create temporary Runtime (for concurrency)
- removed index freezing

The latter was only for precondition checking of
internal code.  At the same time, freezing could
lead to spurious races if Runtime is used
concurrently.

Note:
- gocodec is a separate package as it is useful
  on its own and that way it can be used without
  pulling all the dependencies of gocode.

Change-Id: Ib59b65084038b616c9fb725cbe152a56b8869416
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2742
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/encoding/gocode/doc.go b/encoding/gocode/doc.go
new file mode 100644
index 0000000..7bf0af6
--- /dev/null
+++ b/encoding/gocode/doc.go
@@ -0,0 +1,20 @@
+// Copyright 2019 CUE Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Package gocode defines functions for extracting CUE definitions from Go code
+// and generating Go code from CUE values.
+//
+// This package is used for offline processing. For converting Go values to and
+// from CUE at runtime, use the gocodec package.
+package gocode