@Shumar_Boris

Какие ошибки могут быть в этом коде go что он не запускается?

Код не компилируется, т.е. отсутствует exe-файл. При попытке запуска в онлайн редакторе на сайте go выводится первая строчка, но потом пишет program exited. С чем это может быть связанно?

package main
import (
	"fmt"
)
func main(){
	//declarating variables
	var objecttype int
	var mass int
	var length int
	var width int
	var hight int
	var density int
	var subjecttype int
	var liquidtype int
	//var viscosity int
	//var thermalconductivity int
	var amount int

	//
	fmt.Printf("Hello, please, carefully read instructions.")
        fmt.Printf("Now please choose a type of the object, material subject (like a cube), or electric (like a transistor). Just enter 1 or 2.")
	fmt.Scan(&objecttype)
	//For object
	if objecttype == 1{  //object
		fmt.Printf("Please enter subject length")
		fmt.Scan(&length)
		fmt.Printf("Please enter subject width")
		fmt.Scan(&width)
		fmt.Printf("Please enter subject hight")
		fmt.Scan(&hight)
		fmt.Printf("Please, enter the mass of the subject")
		fmt.Scan(&mass)
		fmt.Printf("Please, enter the density of the subject")
		fmt.Scan(&density)
		fmt.Printf("Please, choose subject type: liquid, metal, non-metal, just type 1, 2 or 3")
		fmt.Scan(&subjecttype)
		//for liquid
		if subjecttype == 1{
			fmt.Printf("Please, select one of existing liquids:")
			fmt.Printf("1 - Mercury")
			fmt.Printf("2 - Glycerol")
			fmt.Printf("3 - Milk")
			fmt.Printf("4 - Sea water")
			fmt.Printf("5 - Water")
			fmt.Printf("6 - Sunflower oil")
			fmt.Printf("7 - Oil")
			fmt.Printf("8 - Alcohol / Ethanol, kerosene")
			fmt.Printf("9 - Petrol")
			fmt.Printf("If your liquid not declared here, type 0")
			fmt.Scan(&liquidtype)
			if liquidtype == 1{
				density = 13600
				//viscosity = 1 //0.001526
				//thermalconductivity = 1 //8.3
				fmt.Printf("Please, enter the mass of the mercury")
				fmt.Scan(&mass)
				fmt.Printf("Please, enter the amount of mercury")
				fmt.Scan(&amount)
			}

		}
	}
}
  • Вопрос задан
  • 198 просмотров
Пригласить эксперта
Ответы на вопрос 1
@h8teveryone
Как вы его пытаетесь скомпилировать?
Только что скомпилировал под Ubunt`ой - всё ок.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы