How to access individual runes using for range loop in GoLang 1.20

Channel:
Subscribers:
5,740
Published on ● Video Link: https://www.youtube.com/watch?v=HiSR0YeeVgc



Category:
Tutorial
Duration: 1:58
5 views
0


In this video we are going to generate source code for the GoLang Program, How to access individual runes using for range loop using chatGPT.
After generating we will verify and run the generated code.

Important note on source code: only source code that are acceptable by the youtube description box will be displayed.

##############SOURCE CODE#########################

package main

import "fmt"

func main() {
str := "Hello, 世界"
for _, r := range str {
fmt.Printf("Rune: %c\n", r)
}
}


Below is the explanation for the program:

In this program, we define a string str with the value "Hello, 世界". The string contains both ASCII and non-ASCII characters.

We then use a for range loop to iterate over each rune of the string.
The for range loop returns two values on each iteration: the index of the current rune (which we don't need, so we use the blank identifier _),
and the rune itself, which we assign to the variable r.

Inside the loop, we use the %c format specifier to print out the current rune.

#go #goprogramming #golang #golangtutorial #golanguage




Other Videos By java frm


2023-04-18How to convert binary number to decimal in Golang 1.20
2023-04-18How to convert binary to ascii in Golang 1.20
2023-04-18How to calculate average of numbers in an array using for range in Golang 1.20
2023-04-18How to print length and capacity of array in GoLang 1.20
2023-04-18How to append elements to slice in GoLang 1.20
2023-04-18How to append data to a file in GoLang 1.20
2023-04-18How to create anonymous struct in GoLang 1.20
2023-04-18How to create struct with fields that contain only a type without the field name in GoLang 1.20
2023-04-18How to add elements to map in GoLang 1.20
2023-04-18How to access and modify individual fields of struct in GoLang 1.20
2023-04-18How to access individual runes using for range loop in GoLang 1.20
2023-04-18How to access individual characters of string using for range loop in GoLang 1.20
2023-04-18How to access and print individual bytes of string in GoLang 1.20
2023-04-18How to connect GoLang to Oracle Database 23c in Windows - Go Oracle Database connectivity - godror
2023-04-18How to connect GoLang to Oracle Database 19c in Windows - Go Oracle Database connectivity - godror
2023-04-18How to connect GoLang to Oracle Database 12c in Windows - Go Oracle Database connectivity - godror
2023-04-18How to remove the entire module download cache in GoLang for Windows - GoLang 1.20
2023-04-18How to Build, install and run Go Programs in Windows - GoLang 1.20
2023-04-15How to install golang 1.20 on Windows 11 from zip archive - GO 1.20 installation on Windows
2023-04-15How to install golang 1.20 on Rocky Linux 8 from zip archive - GO 1.20 installation on linux
2023-04-15How to install golang 1.20 on Red Hat Enterprise Linux 8 from zip - GO 1.20 installation on linux



Tags:
Go Programming Tutorial
Go By example
Go Language
go projects
go programming projects
go tutorial
golang tutorial
golang projects
go programming course
learn go
how to run go program
golang videos
golang with chatgpt
coding questions
coding interview questions