Skip to content

Instantly share code, notes, and snippets.

@basicmag
Created August 13, 2023 08:18
Show Gist options
  • Save basicmag/58fc02ed8b81f5adeb2a6ae0d854e872 to your computer and use it in GitHub Desktop.
Save basicmag/58fc02ed8b81f5adeb2a6ae0d854e872 to your computer and use it in GitHub Desktop.
Go言語: strconv.Atoiで文字列をintに変換する
// Go言語 必読本 Essential Go
// https://www.amazon.co.jp/dp/B0CF53VMYB
//
// Go言語: strconv.Atoiで文字列をintに変換する
package main
import (
"fmt"
"log"
"strconv"
)
func main() {
s := "-48"
i1, err := strconv.Atoi(s)
if err != nil {
log.Fatalf("strconv.Atoi() failed with %s\n", err)
}
fmt.Printf("i1: %d\n", i1)
}
// Go言語 必読本 Essential Go
// https://www.amazon.co.jp/dp/B0CF53VMYB
//
// Essential Go
// https://www.programming-books.io/essential/go/
// By Krzysztof Kowalczyk
//
// Content is licensed under Creative Commons Attribution-ShareAlike 3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment