
前言
作为一名PHP程序员,我感到荣幸。但在时代不断的变迁中,要具备足够的知识才可生存。
那就从Go语言学起把。
希望看到本篇文章的你可以对Go有一个基本的认识。本系列文章与我自己学习Go语言的方式去描述。以PHP代码与Go代码的对比加以区分理解。
变量
PHP
// 初始化变量
$domain = "blog.fastrun.cn";
// 批量赋值
$domain = $domain1 = $domain2 = "blog.fastrun.cn";
Go
// 初始化变量
var domain string = "blog.fastrun.cn"
// 批量赋值
var domain,domain1,domain2 string = "blog.fastrun.cn"
// 批量声明赋值
var username,age,local = "zhangsan",13,"BeiJing"
var(
username="zhangsan"
age = 13
local = "BeiJing"
)
常量
PHP
define("FOO","something");
Go
// 单独声明
const FOO [string]= something
// 批量声明
const (
USERNAME = "zhangsan"
AGE = 30
)
打印
PHP
// 基本输出
echo "blog.fastrun.cn";
// 格式化输出
printf("my blog %s","blog.fastrun.cn");
Go
// 基本输出
fmt.Println("blog.fastrun.cn")
// 格式化输出
fmt.Printf("my blog %s","blog.fastrun.cn")
函数
PHP
// 基本声明
function printString(string $string){
echo $string;
}
// 带返回值
function printString(string $string) : string{
return $string;
}
Go
// 基本声明
func printString(s string){
fmt.Println(s)
}
// 带返回值
func printString(s string) string{
return s
}
致谢
感谢你看到这里,希望本篇文章可以帮到你。谢谢
原创文章,作者:CrazyCodes,如若转载,请注明出处:https://blog.fastrun.cn/2018/10/27/1-71/
评论列表(25条)
Awesome things here. I am very satisfied to see your post.
Thanks a lot and I’m looking ahead to touch you. Will you kindly drop me
a mail?
hello there and thank you for your info – I’ve definitely picked up something new
from right here. I did however expertise a few technical points using
this site, since I experienced to reload the web site lots of times previous to I
could get it to load correctly. I had been wondering if your web host is OK?
Not that I am complaining, but sluggish loading instances
times will often affect your placement in google and could damage your
quality score if advertising and marketing with Adwords.
Anyway I am adding this RSS to my email and could look out for much
more of your respective interesting content. Ensure that you update this
again very soon.
Have you ever considered creating an ebook or guest authoring on other
sites? I have a blog based on the same subjects you discuss and would love to have
you share some stories/information. I know my subscribers
would enjoy your work. If you’re even remotely interested, feel free to send
me an email.
Everyone loves what you guys are usually up too. This
kind of clever work and coverage! Keep up the good works
guys I’ve incorporated you guys to my blogroll.
Everyone loves it when folks come together and share opinions.
Great website, continue the good work!
Please let me know if you’re looking for a writer
for your blog. You have some really good posts and I feel I would be a good asset.
If you ever want to take some of the load off, I’d love to write some material for your blog in exchange for a link back to
mine. Please shoot me an e-mail if interested. Thank you!
Thanks for some other excellent article. Where else may anybody get that kind of information in such
an ideal means of writing? I have a presentation next week,
and I’m on the search for such info.
Hey there! I just wanted to ask if you ever have any issues with
hackers? My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due to no back up.
Do you have any methods to prevent hackers?
@AGEN JUDI:If you don’t have a backup and the server doesn’t have a snapshot, it’s hard to get it back. I’m sorry
Hmm it appears like your website ate my first comment (it was super long) so I guess I’ll
just sum it up what I had written and say, I’m thoroughly enjoying your blog.
I too am an aspiring blog blogger but I’m still new to everything.
Do you have any recommendations for novice blog writers? I’d certainly appreciate
it.
Every weekend i used to go to see this site, as i want enjoyment, for the reason that
this this web site conations in fact fastidious funny material too.
Wonderful website. A lot of helpful info here. I’m sending
it to some buddies ans additionally sharing in delicious.
And obviously, thanks for your sweat!
I truly love your site.. Very nice colors & theme. Did you create this web site yourself?
Please reply back as I’m attempting to create my
own personal site and would like to find out where you got this from or what the theme is named.
Thank you!
@online dating:this hankin template , you can do google search
I do consider all of the ideas you have offered
in your post. They’re really convincing and will certainly work.
Nonetheless, the posts are too brief for beginners. May just you please extend them a bit from subsequent time?
Thanks for the post.
Thanks for ones marvelous posting! I definitely enjoyed reading
it, you can be a great author.I will be sure to
bookmark your blog and may come back later in life.
I want to encourage you to ultimately continue your great writing, have a nice morning!
@Remco Melis:thinks
I think the admin of this site is in fact working hard in favor of his
website, since here every information is quality based information.
@iphone 7 case kate spade:thinks
Hey there! Do you use Twitter? I’d like to follow you if that would
be okay. I’m absolutely enjoying your blog and look forward to new updates.
Thank you for sharing your thoughts. I truly appreciate your efforts and I am
waiting for your next post thank you once again.
This piece of writing will help the internet people for creating
new weblog or even a blog from startt too end.
I enjoy reading a post that can make men and women think.
Also, thank you for allowing me to comment!
I like the helpful info you provide in your articles.
I will bookmark your weblog and check again here frequently.
I am quite certain I will learn many new stuff right here!
Good luck for the next!
@michael kors rhea backpack:thinks