WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Go - Constants


Constants may be of any of the basic statistics sorts like an integer consistent, a floating consistent, a character constant, or a string literal.

Integer Literals

An integer literal can be a decimal, octal, or hexadecimal regular. A prefix specifies the base or radix: 0x or 0X for hexadecimal, zero for octal, and nothing for decimal.

Here are a few examples of integer literals
212         /* Legal */
215u        /* Legal */
0xFeeL      /* Legal */
078         /* Illegal: eight isn't an octal digit */
032UU       /* Illegal: can not repeat a suffix */

Floating-point Literals

A floating-factor literal has an integer part, a decimal point, a fractional element, and an exponent part. The signed exponent is brought by way of e or E.
3.14159       /* Legal */
314159E-5L    /* Legal */
510E          /* Illegal: incomplete exponent */
210f          /* Illegal: no decimal or exponent */
.E55          /* Illegal: lacking integer or fraction */

Escape Sequence

Sequence codes that are used to represent newline (n), tab (t), backspace, etc.
Escape series Meaning
individual
' ' individual
" " man or woman
? ? Person
a Alert or bell
b Backspace
f Form feed
n Newline
r Carriage return
t Horizontal tab
v Vertical tab
ooo Octal range of one to a few digits
xhh . . . Hexadecimal variety of 1 or more digits

The following example suggests how to use t and " in a application

package deal essential

import "fmt"

func important() 
   fmt.Printf("HellotWorld! "welookups" ")



Output

$pass run foremost.Pass
Hello	World! "Welookups" 

String Literals in Go

String literals or constants are enclosed in double charges "".A string includes characters that are much like man or woman literals: undeniable characters, get away sequences, and accepted characters.

"hiya, MASTER"

"hiya, 

pricey"

"whats up, " "M" "ASTER"

The const Keyword

You can use const prefix to claim constants with a selected type as follows
const variable kind = cost;
The following example shows the way to use the const keyword
package deal main

import "fmt"

func most important() 
   const LENGTH int = 12
   const WIDTH int = 6  
   var location int

   location = LENGTH * WIDTH
   fmt.Printf("price of region : %d", location)   

When the above code is compiled and finished, it produces the following result
$pass run foremost.Pass
fee of place : 72