how to convert pointer to string in golang?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

To convert pointer to string in golang, just assign pointer to another variable then you will able to see his value just make sure pointer is not nil.

Follow the below tutorial if you are struggling with installing GO in windows.

Today, I will show you how do I convert pointer to string in golang, as above mentioned I’m going to use assign pointer to another variable to get string.

Let’s start our Golang convert pointer to string example


package main

import "fmt"

func main() {
	var strPointer = new(string)
	*strPointer = "aGuideHub"

	strPointerValue := *strPointer

In the above example, we have converted type *pointer to string and printed in golang console. let’s check the output.



I hope it helps you, All the best 👍.

Try it Yourself

Premium Content

You can get all the below premium content directly in your mail when you subscribe us


Interview Questions

Soon You will get CSS, JavaScript, React Js, and TypeScript So Subscribe to it.

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

Related Posts