Source file test/abi/struct_3_string_input.go

     1  // run
     2  
     3  //go:build !wasm
     4  // +build !wasm
     5  
     6  // Copyright 2021 The Go Authors. All rights reserved.
     7  // Use of this source code is governed by a BSD-style
     8  // license that can be found in the LICENSE file.
     9  
    10  // wasm is excluded because the compiler chatter about register abi pragma ends up
    11  // on stdout, and causes the expected output to not match.
    12  
    13  package main
    14  
    15  import (
    16  	"fmt"
    17  )
    18  
    19  var sink *string
    20  
    21  type toobig struct {
    22  	a, b, c string
    23  }
    24  
    25  //go:registerparams
    26  //go:noinline
    27  func H(x toobig) string {
    28  	return x.a + " " + x.b + " " + x.c
    29  }
    30  
    31  func main() {
    32  	s := H(toobig{"Hello", "there,", "World"})
    33  	gotVsWant(s, "Hello there, World")
    34  }
    35  
    36  func gotVsWant(got, want string) {
    37  	if got != want {
    38  		fmt.Printf("FAIL, got %s, wanted %s\n", got, want)
    39  	}
    40  }
    41  

View as plain text