1// run 2 3// Copyright 2022 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 7package main 8 9import ( 10 "strconv" 11 "sync/atomic" 12 "unsafe" 13) 14 15type t struct { 16 i1 atomic.Int32 17 i2 atomic.Int64 18} 19 20var v t 21 22func main() { 23 if o := unsafe.Offsetof(v.i2); o != 8 { 24 panic("unexpected offset, want: 8, got: " + strconv.Itoa(int(o))) 25 } 26} 27