THANK_GO Telegram 154
Или

Допустим, ваше приложение по умолчанию слушает на порту 8080. Порт можно изменить, задав переменную окружения PORT. Как бы реализовать это в коде?

Можно так:

port := os.Getenv("PORT")
if port == "" {
port = "8080"
}


А с функцией cmp.Or можно компактнее:

port := cmp.Or(os.Getenv("PORT"), "8080")


Or принимает любое количество аргументов и возвращает первый ненулевой. Работает в 1.22+

Мелочь, но приятная.



tgoop.com/thank_go/154
Create:
Last Update:

Или

Допустим, ваше приложение по умолчанию слушает на порту 8080. Порт можно изменить, задав переменную окружения PORT. Как бы реализовать это в коде?

Можно так:

port := os.Getenv("PORT")
if port == "" {
port = "8080"
}


А с функцией cmp.Or можно компактнее:

port := cmp.Or(os.Getenv("PORT"), "8080")


Or принимает любое количество аргументов и возвращает первый ненулевой. Работает в 1.22+

Мелочь, но приятная.

BY Thank Go!


Share with your friend now:
tgoop.com/thank_go/154

View MORE
Open in Telegram


Telegram News

Date: |

The imprisonment came as Telegram said it was "surprised" by claims that privacy commissioner Ada Chung Lai-ling is seeking to block the messaging app due to doxxing content targeting police and politicians. Activate up to 20 bots The best encrypted messaging apps Invite up to 200 users from your contacts to join your channel A few years ago, you had to use a special bot to run a poll on Telegram. Now you can easily do that yourself in two clicks. Hit the Menu icon and select “Create Poll.” Write your question and add up to 10 options. Running polls is a powerful strategy for getting feedback from your audience. If you’re considering the possibility of modifying your channel in any way, be sure to ask your subscribers’ opinions first.
from us


Telegram Thank Go!
FROM American