| 1 |
// Copyright 2023 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 |
// Issue 62430: a program that uses plugins may appear |
| 6 |
// to have no references to an initialized global map variable defined |
| 7 |
// in some stdlib package (ex: unicode), however there |
| 8 |
// may be references to that map var from a plugin that |
| 9 |
// gets loaded. |
| 10 |
|
| 11 |
package main |
| 12 |
|
| 13 |
import ( |
| 14 |
"fmt" |
| 15 |
"plugin" |
| 16 |
"unicode" |
| 17 |
) |
| 18 |
|
| 19 |
func main() { |
| 20 |
p, err := plugin.Open("issue62430.so") |
| 21 |
if err != nil { |
| 22 |
panic(err) |
| 23 |
} |
| 24 |
s, err := p.Lookup("F") |
| 25 |
if err != nil { |
| 26 |
panic(err) |
| 27 |
} |
| 28 |
|
| 29 |
f := s.(func(string) *unicode.RangeTable) |
| 30 |
if f("C") == nil { |
| 31 |
panic("unicode.Categories not properly initialized") |
| 32 |
} else { |
| 33 |
fmt.Println("unicode.Categories properly initialized") |
| 34 |
} |
| 35 |
} |