In golang, if the data type is known to be an integer, does it make a difference if fmt uses% v or% d output?

In
golang, does it make a difference if fmt uses% v or% d output if the data type is known to be an integer?

for example, the following code:

package main

import "fmt"

func main() {
    var d int = 666
    fmt.Printf("type d output is %d", d)
    fmt.Printf("type v outout is %v", d)
}

output

type d output is 666
type v outout is 666

what"s the difference between the two? if there"s no difference, is it possible that all fmt uses% v

Nov.29,2021

% d prints in decimal form, while% v is the default format, which can be changed according to your preferences, simply by copying the String () method.

take a look at this link
https://stackoverflow.com/que.


generally makes no difference, but% v is converted by the String function of the type, and if you don't override the String function of the type you want to output, they are consistent. And% d is fixed, that is, the output number.


  1. v has at least one more function call than d to do type conversion.
  2. % v is intended to allow you to customize the format of the output value.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4c6c2-4d24d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4c6c2-4d24d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?