From 3ebb2f74a8c95208243212fd828bc20b2db52db9 Mon Sep 17 00:00:00 2001 From: Tesfay-Hagos Date: Wed, 25 Jan 2023 17:02:25 +0300 Subject: [PATCH] Update main.go --- .../02-strings/exercises/04-count-the-chars/main.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/08-numbers-and-strings/02-strings/exercises/04-count-the-chars/main.go b/08-numbers-and-strings/02-strings/exercises/04-count-the-chars/main.go index f34dd7867..571e75bce 100644 --- a/08-numbers-and-strings/02-strings/exercises/04-count-the-chars/main.go +++ b/08-numbers-and-strings/02-strings/exercises/04-count-the-chars/main.go @@ -1,16 +1,9 @@ -// Copyright © 2018 Inanc Gumus -// Learn Go Programming Course -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ -// -// For more tutorials : https://learngoprogramming.com -// In-person training : https://www.linkedin.com/in/inancgumus/ -// Follow me on twitter: https://twitter.com/inancgumus - package main import ( "fmt" "os" + "unicode/utf8" ) // --------------------------------------------------------- @@ -33,6 +26,6 @@ func main() { // // When you run it with "İNANÇ", it should return 5 not 7. - length := len(os.Args[1]) - fmt.Println(length) + length := utf8.RuneCountInString(os.Args[1]) + fmt.Println("The length of characters in this string is",length) }