github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/x/tools/go/gcimporter15/setname15.go (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build go1.5,!go1.6 6 7 package gcimporter 8 9 import ( 10 "go/types" 11 "unsafe" 12 ) 13 14 func setName(pkg *types.Package, name string) { 15 (*types_Package)(unsafe.Pointer(pkg)).name = name 16 } 17 18 // The underlying type of types_Package is identical to 19 // the underlying type of types.Package. We use it with 20 // package unsafe to set the name field since 1.5 does 21 // not have the Package.SetName method. 22 // TestSetName verifies that the layout with respect to 23 // the name field is correct. 24 type types_Package struct { 25 path string 26 name string 27 scope *types.Scope 28 complete bool 29 imports []*types.Package 30 fake bool 31 }