If you're comfortable with assembly, Go is capable of including asssembly functions, although they won't be inlined. Place a file ending in .s in your module folder, and add something like (this if you're targeting x86):
TEXT ·FlipByte(SB),7,$0 MOVQ addr+0(FP), BP // This gets the address of the byte pointed to.
MOVL 0(BP), DX // This stores the byte in DX
MOVL $7, CX // Use the CX register as a loop counter
XORL AX, AX // Clear the AX register, to store the result in
loop: // This is a label to be jumped to.
SHLL DX, $1 // Shift the byte in DX right, pushing the leftmost bit into the carry flag
RCLL AX, $1 // Rotate with carry the value in AX to the left, pushing the bit in the carry flag to the leftmost position in AX.
DEC CX // Decrement the counter by one
JNZ loop // Jump to the loop label if the counter isn't zero
MOVL AX, 0(BP) //Move the result back into the address of the byte pointed to (modify the value pointed to by the pointer passed into the function).
RET //Return from the function
Then declare somewhere in your .go file for that module
func FlipByte(addr *byte)
After that, you should be able to call FlipByte like any other function. Note that I haven't tested the above, and I'm not entirely sure about the order of SHLL and RCLL, so if SHLL $1,AX doesn't work, try SHLL AX,$1 . I'm also not sure if Go supports the RCL (rotate with carry function), but if not you can still use it via machine code, like:
BYTE $0x__; BYTE $0x__; BYTE $0x__;
Where the __ values are the opcodes for RCL.