Skip to content

Instantly share code, notes, and snippets.

@basicmag
Created August 13, 2023 22:17
Show Gist options
  • Save basicmag/5b9ff6e21d8c91f36ef29e9f37972300 to your computer and use it in GitHub Desktop.
Save basicmag/5b9ff6e21d8c91f36ef29e9f37972300 to your computer and use it in GitHub Desktop.

Revisions

  1. basicmag created this gist Aug 13, 2023.
    27 changes: 27 additions & 0 deletions 011_characters1.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    // Go言語 必読本 Essential Go
    // https://www.amazon.co.jp/dp/B0CF53VMYB
    //
    // Go言語: バイトを使った文字列のループ処理

    package main

    import (
    "fmt"
    )

    func main() {
    s := "str"
    for i := 0; i < len(s); i++ {
    c := s[i]
    fmt.Printf("Byte at index %d is '%c' (0x%x)\n", i, c, c)
    }
    }

    // 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