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 141 views
4 answers 244 views
1 answer 156 views
1 answer 176 views
176 views asked Aug 19, 2020 by avibootz
2 answers 320 views
1 answer 176 views
...