I
I
Ivan2021-04-30 15:17:45
go
Ivan, 2021-04-30 15:17:45

How to check if a string has certain characters at the beginning?

Good afternoon. More precisely, you need to check if there is a https://. If there is, leave it as is; if not, stick it on. It is clear that if, but how to actually check if there is at the beginning https://?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2021-04-30
@Djonson86

strings.HasPrefix("Gopher", "Go")
Documentation here

L
Lynn "Coffee Man", 2021-04-30
@Lynn

RTFM https://golang.org/pkg/strings/#HasPrefix

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question