github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/test/fixedbugs/bug059.go (about)

     1  // run
     2  
     3  // Copyright 2009 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  import "os"
    10  
    11  func P(a []string) string {
    12  	s := "{";
    13  	for i := 0; i < 2; i++ {
    14  		if i > 0 {
    15  			s += ","
    16  		}
    17  		s += `"` + a[i] + `"`;
    18  	}
    19  	s +="}";
    20  	return s;
    21  }
    22  
    23  func main() {
    24  	m := make(map[string] []string);
    25  	as := new([2]string);
    26  	as[0] = "0";
    27  	as[1] = "1";
    28  	m["0"] = as[0:];
    29  
    30  	a := m["0"];
    31  	a[0] = "x";
    32  	m["0"][0] = "deleted";
    33  	if m["0"][0] != "deleted" {
    34  		os.Exit(1);
    35  	}
    36  }