1// Copyright 2020 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// Test that read-only data is indeed read-only. This 6// program attempts to modify read-only data, and it 7// should fail. 8 9package main 10 11import "unsafe" 12 13var s = "hello" 14 15func main() { 16 println(s) 17 *(*struct { 18 p *byte 19 l int 20 })(unsafe.Pointer(&s)).p = 'H' 21 println(s) 22} 23