github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/blog/support/racy/racy.go (about)

     1  // Copyright 2013 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  // +build !appengine
     6  
     7  // This program demonstrates a race condition.
     8  // To observe the race with the race detector, build with -race.
     9  package main
    10  
    11  import "fmt"
    12  
    13  func main() {
    14  	done := make(chan bool)
    15  	m := make(map[string]string)
    16  	m["name"] = "world"
    17  	go func() {
    18  		m["name"] = "data race"
    19  		done <- true
    20  	}()
    21  	fmt.Println("Hello,", m["name"])
    22  	<-done
    23  }