How to print a double-quotes string in Go

3 Answers

0 votes
package main 
    
import ( 
    "fmt"
    "strconv"
) 
 
func main() { 
    str := "go java c c++ python"

	fmt.Println(strconv.Quote(str))
} 
    
     
     
   
      
/*
run:
       
"go java c c++ python"
   
*/

 



answered Jun 10, 2023 by avibootz
0 votes
package main 
    
import ( 
    "fmt"
) 
 
func main() { 
    str := "go java c c++ python"

	fmt.Printf("%q", str)
} 
    
     
     
   
      
/*
run:
       
"go java c c++ python"
   
*/

 



answered Jun 10, 2023 by avibootz
0 votes
package main 
    
import ( 
    "fmt"
) 
 
func main() { 
    str := "go java c c++ python"
    
    fmt.Printf("\"%s\"", str)
} 
    
     
     
   
      
/*
run:
       
"go java c c++ python"
   
*/

 



answered Jun 10, 2023 by avibootz

Related questions

1 answer 145 views
4 answers 251 views
1 answer 164 views
1 answer 184 views
184 views asked Aug 19, 2020 by avibootz
2 answers 325 views
1 answer 183 views
...