Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6255817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:26:08+00:00 2026-05-24T14:26:08+00:00

SO, I need your help. I couldn’t find anything on that topic. Golang is

  • 0

SO, I need your help. I couldn’t find anything on that topic. Golang is a freshly baked language so it’s quite hard to find answers quick for a newcomers like me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:26:09+00:00Added an answer on May 24, 2026 at 2:26 pm

    The predeclared Go int type size is implementation-specific, either 32 or 64 bits (Numeric types).

    Here’s an example of converting big-endian ints to bytes (uint8s).

    package main
    
    import (
        "encoding/binary"
        "fmt"
        "reflect"
    )
    
    func IntsToBytesBE(i []int) []byte {
        intSize := int(reflect.TypeOf(i).Elem().Size())
        b := make([]byte, intSize*len(i))
        for n, s := range i {
            switch intSize {
            case 64 / 8:
                binary.BigEndian.PutUint64(b[intSize*n:], uint64(s))
            case 32 / 8:
                binary.BigEndian.PutUint32(b[intSize*n:], uint32(s))
            default:
                panic("unreachable")
            }
        }
        return b
    }
    
    func main() {
        i := []int{0, 1, 2, 3}
        fmt.Println("int size:", int(reflect.TypeOf(i[0]).Size()), "bytes")
        fmt.Println("ints:", i)
        fmt.Println("bytes:", IntsToBytesBE(i))
    }
    

    Output:

    int size: 4 bytes
    ints: [0 1 2 3]
    bytes: [0 0 0 0 0 0 0 1 0 0 0 2 0 0 0 3]
    

    or

    int size: 8 bytes
    ints: [0 1 2 3]
    bytes: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 3]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need your help. I have been switching from various libraries trying to find
i really need some help on this. I searched the internet but couldn't find
Need your help to get the max of CAP_PRICE based on certain criteria in
I need your help. Say I have a code inside a for statement similar
I need your help again :) I'm trying to do a plugin with jQuery
I need your help. I'm trying to install php_apc.dll into my php directory. So
I need your help to translate a query into pyes. This query is working
I need your help. I have a php script to send email to people
I need your help with this one again. I want to send special characters
I really need your help for this. I am relatively new to programming and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.