O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Greeting the human

The Greeting method is used to provide a first-time greeting to the user when the live chat feature is activated:

func (a *AgentCase) Greeting() string {  sampleQuestionIndex := randomNumber(0, len(a.sampleQuestions))  greeting := "Hi there! I'm Case. You can ask me a question on Isomorphic Go. Such as...\"" + a.sampleQuestions[sampleQuestionIndex] + "\""  return greeting}

Since the greeting will include a randomly selected sample question that can be asked to Case, the randomNumber function is called to obtain the index number of the sample question. We pass the minimum value and the maximum value to the randomNumber function to specify the range that the produced random number should be in.

Here's the randomNumber function ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required