Source file test/fixedbugs/issue63505.go

     1  // compile
     2  
     3  // Copyright 2023 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package main
     8  
     9  type explainer struct {
    10  	m map[string]string
    11  }
    12  
    13  func init() {
    14  	RegisterExplainer(newExplainer())
    15  }
    16  
    17  type Explainer interface {
    18  	Name() string
    19  	Map() map[string]string
    20  }
    21  
    22  func (e explainer) Name() string {
    23  	return "HelloWorldExplainer"
    24  }
    25  
    26  func (e explainer) Map() map[string]string {
    27  	return e.m
    28  }
    29  
    30  //go:noinline
    31  func newExplainer() explainer {
    32  	m := make(map[string]string)
    33  	m["Hello"] = "World!"
    34  	return explainer{m}
    35  }
    36  
    37  var explainers = make(map[string]Explainer)
    38  
    39  func RegisterExplainer(e Explainer) {
    40  	explainers[e.Name()] = e
    41  }
    42  
    43  func main() {
    44  
    45  }
    46  

View as plain text