c++ in go. my code snippet is like this-
                  
                  
                  
                  
                  
                  struct CommonHeader
                  
                  
                  {
                  
                  
                  #if defined(MS_LITTLE_ENDIAN)
                  
                  
                    uint8_t count : 5;
                  
                  
                    uint8_t padding : 1;
                  
                  
                    uint8_t version : 2;
                  
                  
                  #elif defined(MS_BIG_ENDIAN)
                  
                  
                    uint8_t version : 2;
                  
                  
                    uint8_t padding : 1;
                  
                  
                    uint8_t count : 5;
                  
                  
                  #endif
                  
                  
                    uint8_t packetType;
                  
                  
                    uint16_t length;
                  
                  
                  };
                  
                  
                  
                  
                  
                  I want the same behaviour in go. so how do I get this? Also I have a function which uses CommonHeader.version.
                  
                  
                
Do u really need different structures for that? I guess you can just adjust parsing function to use either little or big endian reader
http://aiju.de/misc/c-style
Обсуждают сегодня