Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to capitalize the first letter of a string

this is my first question!

So here’s my question.

I have a string like this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

var sentence string
string = "the biggest ocean is the Pacific ocean"

I want to be able to make the t in the to be capitalized so the string is

"The biggest ocean is the Pacific ocean"

Thanks for any replies!

>Solution :

I have simple solution for you.

Its a fork I have of someones project on Github

https://github.com/CleanMachine1/capitalise

To use it just run in a terminal:

go mod init MODULENAME
go get github.com/cleanmachine1/capitalise

then in your code you can use


package main

import ("github.com/cleanmachine1/capitalise")

func main(){
 sentence = capitalise.First(sentence)
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading