Определить тип переменной в Go

Содержание
Introduction
Пример
В других языках

Introduction

Пример

package main import ( "fmt" "reflect" ) func main() { var_str := "string" var_int := 10 var_float64 := 1.2 var_bool := true var_complex128 := complex(2, 3) r, im := real(var_complex128), imag(var_complex128) fmt.Println(reflect.TypeOf(var_str)) fmt.Println(reflect.TypeOf(var_int)) fmt.Println(reflect.TypeOf(var_float64)) fmt.Println(reflect.TypeOf(var_bool)) fmt.Println(reflect.TypeOf(var_complex128)) fmt.Println(reflect.TypeOf(r), reflect.TypeOf(im)) }

string
int
float64
bool
complex128
float64 float64

В других языках

Article author: Andrei Olegovich

Похожие статьи
Development на Go
Объявление переменных
Определить тип переменной
Указатели
Константы
Установка в Linux
Go course: zero to hero in 50 lessons
Make
Banner image

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: