github.com/ltltlt/go-source-code@v0.0.0-20190830023027-95be009773aa/go/types/testdata/importC.src (about) 1 // Copyright 2015 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 package importC 6 7 import "C" 8 import _ /* ERROR cannot rename import "C" */ "C" 9 import foo /* ERROR cannot rename import "C" */ "C" 10 import . /* ERROR cannot rename import "C" */ "C" 11 12 // Test cases extracted from issue #22090. 13 14 import "unsafe" 15 16 const _ C.int = 0xff // no error due to invalid constant type 17 18 type T struct { 19 Name string 20 Ordinal int 21 } 22 23 func f(args []T) { 24 var s string 25 for i, v := range args { 26 cname := C.CString(v.Name) 27 args[i].Ordinal = int(C.sqlite3_bind_parameter_index(s, cname)) // no error due to i not being "used" 28 C.free(unsafe.Pointer(cname)) 29 } 30 } 31 32 type CType C.Type 33 34 const _ CType = C.X // no error due to invalid constant type 35 const _ = C.X