cannot use phone (type string) as type int in assignment [duplicate]Convert string to integer type in Go?In Go, one type is coerced into another, can a method to determine the type of the receiver?Why can't I put the opening braces on the next line?Type conversion of string to intStruct type immtable“goapp build” works, but “appcfg.py update” just “can't find import”…?cannot use Context as type “handlerfunc” gin-gonicCan't make a slice of a column of a 2d array “cannot use Sudoku[0:9][0] (type [9]int) as type []int in assignment”Golang import struct and share over all apphow do i resolve cannot refer to unexported field or method models.Model.getDevices in golangwhy my code error (mssql: Violation of PRIMARY KEY constraint 'PK_SMSBlast2'. Cannot insert duplicate key in object 'dbo.SMSBlast2')?

Why does Mjolnir fall down in Age of Ultron but not in Endgame?

Alternatives to achieve certain output format

Popcorn is the only acceptable snack to consume while watching a movie

Is "cool" appropriate or offensive to use in IMs?

My employer faked my resume to acquire projects

Parallel fifths in the orchestra

Efficient Algorithm for the boundary of a set of tiles

Is it legal to have an abortion in another state or abroad?

Make 24 using exactly three 3s

Why did the person in charge of a principality not just declare themself king?

When the Torah was almost lost and one (or several) Rabbis saved it?

How to deal with a colleague who is being aggressive?

Need to understand my home electrical meter to see why bill is so high and/or if neighbor is on same meter

How to politely tell someone they did not hit "reply to all" in an email?

Count rotary dial pulses in a phone number (including letters)

Of strange atmospheres - the survivable but unbreathable

Can the product of any two aperiodic functions which are defined on the entire number line be periodic?

Does pair production happen even when the photon is around a neutron?

What is a Power on Reset IC?

I know that there is a preselected candidate for a position to be filled at my department. What should I do?

How to respond to upset student?

Is the field of q-series 'dead'?

Ingress filtering on edge routers and performance concerns

The art of clickbait captions



cannot use phone (type string) as type int in assignment [duplicate]


Convert string to integer type in Go?In Go, one type is coerced into another, can a method to determine the type of the receiver?Why can't I put the opening braces on the next line?Type conversion of string to intStruct type immtable“goapp build” works, but “appcfg.py update” just “can't find import”…?cannot use Context as type “handlerfunc” gin-gonicCan't make a slice of a column of a 2d array “cannot use Sudoku[0:9][0] (type [9]int) as type []int in assignment”Golang import struct and share over all apphow do i resolve cannot refer to unexported field or method models.Model.getDevices in golangwhy my code error (mssql: Violation of PRIMARY KEY constraint 'PK_SMSBlast2'. Cannot insert duplicate key in object 'dbo.SMSBlast2')?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-4
















This question already has an answer here:



  • Convert string to integer type in Go?

    5 answers



I have an error "cannot use phone (type string) as type int in assignment",
how to fix this?



I use in github.com/gin-gonic/gin and github.com/jinzhu/gor



 package main

import (
"github.com/jinzhu/gorm"
"github.com/gin-gonic/gin"
)

type Employees struct
gorm.Model
Phone int


func (idb *InDB) CreateEmployees(c *gin.Context)
var (
em models.Employees
result gin.H
)

phone := c.PostForm("phone")
em.Phone = phone

result = gin.H
"result": em,

c.JSON(http.StatusOK, result)










share|improve this question















marked as duplicate by peterSO go
Users with the  go badge can single-handedly close go questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 3:17


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • A phone number is not an integer. Why are you declaring it as one? How is (555) 555-5555 an integer value? You can do math operations on an int. How do you do that with a phone number? How do you multiply a phone number by 2?

    – Ken White
    Mar 24 at 2:55


















-4
















This question already has an answer here:



  • Convert string to integer type in Go?

    5 answers



I have an error "cannot use phone (type string) as type int in assignment",
how to fix this?



I use in github.com/gin-gonic/gin and github.com/jinzhu/gor



 package main

import (
"github.com/jinzhu/gorm"
"github.com/gin-gonic/gin"
)

type Employees struct
gorm.Model
Phone int


func (idb *InDB) CreateEmployees(c *gin.Context)
var (
em models.Employees
result gin.H
)

phone := c.PostForm("phone")
em.Phone = phone

result = gin.H
"result": em,

c.JSON(http.StatusOK, result)










share|improve this question















marked as duplicate by peterSO go
Users with the  go badge can single-handedly close go questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 3:17


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • A phone number is not an integer. Why are you declaring it as one? How is (555) 555-5555 an integer value? You can do math operations on an int. How do you do that with a phone number? How do you multiply a phone number by 2?

    – Ken White
    Mar 24 at 2:55














-4












-4








-4









This question already has an answer here:



  • Convert string to integer type in Go?

    5 answers



I have an error "cannot use phone (type string) as type int in assignment",
how to fix this?



I use in github.com/gin-gonic/gin and github.com/jinzhu/gor



 package main

import (
"github.com/jinzhu/gorm"
"github.com/gin-gonic/gin"
)

type Employees struct
gorm.Model
Phone int


func (idb *InDB) CreateEmployees(c *gin.Context)
var (
em models.Employees
result gin.H
)

phone := c.PostForm("phone")
em.Phone = phone

result = gin.H
"result": em,

c.JSON(http.StatusOK, result)










share|improve this question

















This question already has an answer here:



  • Convert string to integer type in Go?

    5 answers



I have an error "cannot use phone (type string) as type int in assignment",
how to fix this?



I use in github.com/gin-gonic/gin and github.com/jinzhu/gor



 package main

import (
"github.com/jinzhu/gorm"
"github.com/gin-gonic/gin"
)

type Employees struct
gorm.Model
Phone int


func (idb *InDB) CreateEmployees(c *gin.Context)
var (
em models.Employees
result gin.H
)

phone := c.PostForm("phone")
em.Phone = phone

result = gin.H
"result": em,

c.JSON(http.StatusOK, result)





This question already has an answer here:



  • Convert string to integer type in Go?

    5 answers







go go-gorm gin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 29 at 9:07









robbieperry22

371220




371220










asked Mar 24 at 2:41









rsmnartsrsmnarts

714




714




marked as duplicate by peterSO go
Users with the  go badge can single-handedly close go questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 3:17


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by peterSO go
Users with the  go badge can single-handedly close go questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 24 at 3:17


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • A phone number is not an integer. Why are you declaring it as one? How is (555) 555-5555 an integer value? You can do math operations on an int. How do you do that with a phone number? How do you multiply a phone number by 2?

    – Ken White
    Mar 24 at 2:55


















  • A phone number is not an integer. Why are you declaring it as one? How is (555) 555-5555 an integer value? You can do math operations on an int. How do you do that with a phone number? How do you multiply a phone number by 2?

    – Ken White
    Mar 24 at 2:55

















A phone number is not an integer. Why are you declaring it as one? How is (555) 555-5555 an integer value? You can do math operations on an int. How do you do that with a phone number? How do you multiply a phone number by 2?

– Ken White
Mar 24 at 2:55






A phone number is not an integer. Why are you declaring it as one? How is (555) 555-5555 an integer value? You can do math operations on an int. How do you do that with a phone number? How do you multiply a phone number by 2?

– Ken White
Mar 24 at 2:55













1 Answer
1






active

oldest

votes


















1














Value in PostForm are all strings. You should declare phone as string type, or convert the phone number from string to integer. Like strconv.Atoi or strconv.ParseInt



phone := c.PostForm("phone")
phoneNumber, _ := strconv.Atoi(phone)
em.Phone = phoneNumber





share|improve this answer































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Value in PostForm are all strings. You should declare phone as string type, or convert the phone number from string to integer. Like strconv.Atoi or strconv.ParseInt



    phone := c.PostForm("phone")
    phoneNumber, _ := strconv.Atoi(phone)
    em.Phone = phoneNumber





    share|improve this answer





























      1














      Value in PostForm are all strings. You should declare phone as string type, or convert the phone number from string to integer. Like strconv.Atoi or strconv.ParseInt



      phone := c.PostForm("phone")
      phoneNumber, _ := strconv.Atoi(phone)
      em.Phone = phoneNumber





      share|improve this answer



























        1












        1








        1







        Value in PostForm are all strings. You should declare phone as string type, or convert the phone number from string to integer. Like strconv.Atoi or strconv.ParseInt



        phone := c.PostForm("phone")
        phoneNumber, _ := strconv.Atoi(phone)
        em.Phone = phoneNumber





        share|improve this answer















        Value in PostForm are all strings. You should declare phone as string type, or convert the phone number from string to integer. Like strconv.Atoi or strconv.ParseInt



        phone := c.PostForm("phone")
        phoneNumber, _ := strconv.Atoi(phone)
        em.Phone = phoneNumber






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 24 at 3:26

























        answered Mar 24 at 2:59









        HolaYangHolaYang

        33919




        33919















            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현