importInitializer calls the imported package $init() function to ensure it is initialized before any code in the importer package runs.
(impPath string)
| 197 | // importInitializer calls the imported package $init() function to ensure it is |
| 198 | // initialized before any code in the importer package runs. |
| 199 | func (fc *funcContext) importInitializer(impPath string) ast.Stmt { |
| 200 | pkgVar := fc.pkgCtx.pkgVars[impPath] |
| 201 | id := fc.newIdent(fmt.Sprintf(`%s.$init`, pkgVar), types.NewSignatureType(nil, nil, nil, nil, nil, false)) |
| 202 | call := &ast.CallExpr{Fun: id} |
| 203 | fc.Blocking[call] = true |
| 204 | fc.Flattened[call] = true |
| 205 | |
| 206 | return &ast.ExprStmt{X: call} |
| 207 | } |
| 208 | |
| 209 | // varDecls translates all package-level variables. |
| 210 | // |