@@ -2,12 +2,11 @@ package main
2
2
3
3
import (
4
4
"fmt"
5
+ "go/token"
5
6
"io"
6
7
"slices"
7
8
"strconv"
8
9
"strings"
9
- "unicode"
10
- "unicode/utf8"
11
10
12
11
"github.com/golang-fips/openssl/v2/internal/mkcgo"
13
12
)
@@ -655,8 +654,7 @@ func goSymName(name string) string {
655
654
// Strip the 'go_' prefix commonly used in shims so Go symbols are nicer.
656
655
name = strings .TrimPrefix (name , "go_" )
657
656
658
- ch , _ := utf8 .DecodeRuneInString (name )
659
- isPrivate := ! unicode .IsUpper (ch )
657
+ isPrivate := ! token .IsExported (name )
660
658
if * private == isPrivate {
661
659
// Same access level, no need to change.
662
660
return name
@@ -811,8 +809,7 @@ func generateNocgoAliases(typedefs []*mkcgo.TypeDef, w io.Writer) {
811
809
for _ , typedef := range typedefs {
812
810
// For basic types, make it an alias to the appropriate Go type
813
811
goType , _ := cTypeToGo (typedef .Type , false )
814
- name := strings .TrimPrefix (typedef .Name , "_" )
815
- name = strings .ToUpper (name [:1 ]) + name [1 :]
812
+ name := goSymName (typedef .Name )
816
813
if goType != "" && goType != "unsafe.Pointer" {
817
814
fmt .Fprintf (w , "type %s = %s\n " , name , goType )
818
815
seenTypes [name ] = true
0 commit comments