Convert int to int32 or int64

3,678 views
Skip to first unread message

bx10000

unread,
Apr 17, 2015, 8:58:00 PM4/17/15
to golan...@googlegroups.com
Is there a way to convert an int to int64?

I know you can convert int to int64 by doing int64(int).

Thanks in advance.

Brad Fitzpatrick

unread,
Apr 17, 2015, 9:08:06 PM4/17/15
to bx10000, golang-nuts
I'm not sure I understand the question. You seem to know the answer?


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cloud

unread,
Apr 17, 2015, 10:09:20 PM4/17/15
to Brad Fitzpatrick, bx10000, golang-nuts
He wants to get the answer seem like `strconv.Itoa`

Blia Xiong

unread,
Apr 18, 2015, 7:00:23 PM4/18/15
to Cloud, Brad Fitzpatrick, golang-nuts
Sorry. Had a brain fart. Convert int64 into int was what I meant. Using a webframe work and it auto created ids of tables as int64. Wanting to concate int to string but the strconv.Itoa takes an int; can't take an int64. 

Maybe I can't do string interpolation?

Thanks so much!!!


--
Sent from Gmail Mobile

Dan Kortschak

unread,
Apr 18, 2015, 7:08:46 PM4/18/15
to Blia Xiong, Cloud, Brad Fitzpatrick, golang-nuts

john...@gmail.com

unread,
Apr 18, 2015, 9:13:05 PM4/18/15
to golan...@googlegroups.com, brad...@golang.org, cl...@txthinking.com


On Saturday, April 18, 2015 at 5:00:23 PM UTC-6, bx10000 wrote:
Sorry. Had a brain fart. Convert int64 into int was what I meant. Using a webframe work and it auto created ids of tables as int64. Wanting to concate int to string but the strconv.Itoa takes an int; can't take an int64. 

Maybe I can't do string interpolation?

Thanks so much!!!

On Friday, April 17, 2015, Cloud <cl...@txthinking.com> wrote:
He wants to get the answer seem like `strconv.Itoa`

This should do it:

myInt := (int)myInt64

Look at the topic conversions in the language spec. Note that this conversion will truncate the value if it doesn't fit into the int.

On Sat, Apr 18, 2015 at 9:08 AM Brad Fitzpatrick <brad...@golang.org> wrote:
I'm not sure I understand the question. You seem to know the answer?

On Fri, Apr 17, 2015 at 5:58 PM, bx10000 <bli...@gmail.com> wrote:
Is there a way to convert an int to int64?

I know you can convert int to int64 by doing int64(int).

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Andy Balholm

unread,
Apr 20, 2015, 12:22:46 PM4/20/15
to john...@gmail.com, golan...@googlegroups.com, brad...@golang.org, cl...@txthinking.com
That looks like a mixture of C and Go syntax. Try

myint := int(myInt64)
Reply all
Reply to author
Forward
0 new messages