Golang两个空结构相等的问题

时间:2018-10-26 14:56:47

标签: go

public function update(Request $request)
{
    $idpawn = $request['idprestamo'];
    $paynumber = $request['numeropago'];
    $payqty = $request['payqty'];
    $statuspawns = statuspawns::find($idpawn,$paynumber);
    $updateqty = $statuspawns->totalpayment - $payqty;

    if($updateqty  == "0"){
        $status = "Pay";
    }
    else{
        $status = "Partial Payment";
    }

    $statuspawns->total = $updateqty;
    $statuspawns->status = $status;
    $statuspawns->save();

    return redirect()->back();
}

以上代码的输出为:

package main

import "fmt"

func main() {
    a := struct{}{}
    b := struct{}{}
    fmt.Println(a == b)
    fmt.Println(&a == &b)
}

但是如果我按如下方式打印true false a的指针:

b

输出为:

package main

import "fmt"

func main() {
    a := struct{}{}
    b := struct{}{}
    fmt.Println(a == b)
    fmt.Println(&a == &b)
    fmt.Printf("%p\n", &a)
    fmt.Printf("%p\n", &b)
}

那为什么打印后输出会改变?

0 个答案:

没有答案