You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import "fmt"
type Transaction struct {
ID int
Status int
}
func main() {
var txns []Transaction
for i := 0; i < 10; i++ {
txns = append(txns, Transaction{ID: i, Status: 0})
}
var ptr []*int
for _, txn := range txns {
fmt.Printf("Transaction ID: %d, Status addr: %p\n", txn.ID, &(txn.Status))
ptr = append(ptr, &(txn.Status))
}
}
running: exportloopref got no error
The text was updated successfully, but these errors were encountered:
@ljw7630 You don't need to wrap txn.Status with braces.
exportloopref cannot find the wrapped pointer.
package main
import "fmt"
type Transaction struct {
ID int
Status int
}
func main() {
var txns []Transaction
for i := 0; i < 10; i++ {
txns = append(txns, Transaction{ID: i, Status: 0})
}
var ptr []*int
for _, txn := range txns {
fmt.Printf("Transaction ID: %d, Status addr: %p\n", txn.ID, &(txn.Status))
ptr = append(ptr, &txn.Status)
}
}
running: exportloopref got no error
The text was updated successfully, but these errors were encountered: