Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
Converting Strings to Integers or Integers to Strings is a common task that developers face every day. The Go Standard Library comes with packages to make this task easier. Go developers need to know to use the standard library and when to look for third-party libraries to solve a task.
Convert A String To An Integer
To convert a string to an integer, we will use the function Atio from the strconv package. This function handles converting the string to an integer for us. Below is a code example of how to do this.
When we run this program, we will see this output::
This tells us that the value is 747 and the data type of int.
Convert A Integer To An String
To convert an integer to a string, we will use the function the Itoa from the strconv package. This function handles converting the integer to a string for us. Below is a code example of how to do this.
When we run this program, we will see this output:
This tells us that the value is 747 and the data type of string.
Originally published at harrisonbrock.com
Converting Strings To Integers And Integers To Strings was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.