什么" | ="运营商意味着Go?

时间:2015-01-14 00:01:42

标签: go

我找到了这个运算符|=,我想知道这意味着什么

func getPageInfoMode(r *http.Request) (mode PageInfoMode) {
    for _, k := range strings.Split(r.FormValue("m"), ",") {
        if m, found := modeNames[strings.TrimSpace(k)]; found {
            mode |= m
        }
    }
    return
}

1 个答案:

答案 0 :(得分:0)

是一个inplace按位OR运算符https://golang.org/ref/spec#Operators

还有很多其他人:

+    &     +=    &=     &&    ==    !=        
-    |     -=    |=     ||    <     <=        
*    ^     *=    ^=     <-    >     >=        
/    <<    /=    <<=    ++    =     :=        
%    >>    %=    >>=    --    !            
&^   &^=