How to delete vowels from string in Golang 1.20

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



Category:
Tutorial
Duration: 1:53
4 views
0


In this video we are going to generate source code for the GoLang Program, How to delete vowels from string 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"
"strings"
)

func main() {
// Example input string
inputString := "Hello, World!"

// Convert the input string to lowercase
inputString = strings.ToLower(inputString)

// Define a string containing vowels
vowels := "aeiou"

// Replace all vowels in the input string with an empty string
outputString := strings.Map(func(r rune) rune {
if strings.ContainsRune(vowels, r) {
return -1
}
return r
}, inputString)

// Output the result
fmt.Println(outputString)
}


Below is the explanation for the program:

In this program, we first convert the input string to lowercase, to ensure that we capture all possible vowels.
Then we define a string containing all the vowels, and use the strings.Map() function to iterate over each character in the input string.
If the character is a vowel, we replace it with an empty string (i.e. delete it). If it is not a vowel, we keep it in the output string.



#go #goprogramming #golang #golangtutorial #golanguage







Tags:
how to delete vowels in string in golang
go program to delete vowels in string
string manipulation in go
strings in go
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