ballerina

How do I read an int from command line in Ballerina?

江枫思渺然 提交于 2020-07-20 14:04:32
问题 any choice = io:readln("Enter choice 1 - 5: "); I cannot seem to cast the input to an int. Both check and match gives the same error var intChoice = <int>choice; match intChoice { int value => c = value; error err => io:println("error: " + err.message); } and c = check <int>choice; gives error: 'string' cannot be cast to 'int' I looked into https://ballerina.io/learn/by-example/type-conversion.html and also studied https://ballerina.io/learn/api-docs/ballerina/io.html#readln but no luck. What

云原生编程语言ballerina:hello-world

允我心安 提交于 2020-02-27 12:51:55
前言 Ballerina是一款完全开源的编译时强类型语言,愿景是让云原生时代的程序员轻松编写出想要的的软件. 开源地址: https://github.com/ballerina-platform/ballerina-lang Example 下载对应平台的包进行安装 https://ballerina.io/downloads/ 这里使用的是在ubuntu环境下安装,下载好deb包后,进行安装 lan@lan-machine:~$ sudo dpkg -i ballerina-linux-installer-x64-1.1.0.deb [sudo] password for lan: Selecting previously unselected package ballerina-1.1.0. (Reading database ... 187196 files and directories currently installed.) Preparing to unpack ballerina-linux-installer-x64-1.1.0.deb ... Unpacking ballerina-1.1.0 (1.1.0) ... Setting up ballerina-1.1.0 (1.1.0) ... lan@lan-machine:~$ ballerina

Ballerina package build failed

旧时模样 提交于 2020-01-16 11:16:46
问题 I followed the Ballerina quick tour on https://ballerina.io/community-program/ and created the package 'Calculator' and everything worked perfectly until the package building step. After the build command is entered an error appears. ballerina build calculator ballerina: Oh no, something really went wrong. Bad. Sad. There should be a file named "ballerina-internal.log" in the current directory. If you are able to share with us the code that broke Ballerina then we would REALLY appreciate if

unable to start ballerina as gateway

强颜欢笑 提交于 2020-01-05 04:41:30
问题 I've downloaded the WSO2-ApiManager-3.0.0-m2 release and I'm trying to invoke an api via the ballerina gateway(version 0.88). When I'm trying to start ballerina with: bin/ballerina run service deployment/org/wso2/apim/ it gives me ballerina: no such file or directory: deployment/org/wso2/apim If I manually create that directory in $gwHome I get ballerina: no bal files in the package: deployment/org/wso2/apim How do I start the ballerina gateway? 回答1: WSO2-ApiManager-3.0.0-m2 works with

Outputtng html by using Ballerina

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 06:59:24
问题 Is there any way to output a html page with some data in it by using Ballerina language? Assume that I need the "orderid" string in the below code to be displayed inside a H1 tag in a HTML page.. import ballerina.net.http; import ballerina.lang.system; @http:BasePath {value:"/shop"} service echo { @http:GET{} @http:Path {value:"/order"} resource echoGet (message m, @http:QueryParam {value:"orderid"}string orderid) { http:convertToResponse(m); system:println("orderid" + orderid); reply m; } }

Ballerina V 1.0 - Error in Calling function with jdbc:Client return type - undocumented return parameter

荒凉一梦 提交于 2019-12-11 04:53:20
问题 I need to call a function in test.bal. Function is written in function.bal file in the same module. Return type of the function is jdbc:Client . function.bal : import ballerinax/java.jdbc; public function createDbConn() returns jdbc:Client{ jdbc:Client testDbConn = new({ url: "jdbc:mysql://localhost:3306/testDB", username: "testUsername", password: "testPassword", poolOptions: {maximumPoolSize: 5}, dbOptions: {useSSL: false} }); return testDbConn; } Before invoking this method in test.bal,

How do you round off float values in Ballerina?

北城以北 提交于 2019-12-11 01:36:19
问题 In BallerinaLang, how do you round off float values to a specified number of decimal places? 回答1: Ballerina has not provided specific method yet for float round off. But using math:round of existing math package, following can be done. import ballerina/math; function roundFloat(float value, int decimalPlaces) returns float { float factor = math:pow(10, decimalPlaces); return <float> math:round(value * factor)/factor; } function main(string... args) { float result = roundFloat(12.84675, 2); }

Deploying the Ballerina integration example in a Docker container

风流意气都作罢 提交于 2019-12-01 09:20:32
On the Ballerina Quick Tour page, there is an example on deploying a previously created integration microservice (which is supposed to send a Tweet) within in a docker container. However, that part of the documentation doesn't describe how to package the "twitter.toml" (authentication details) within the container. Therefore, it doesn't work as it does when it wasn't deployed within a container. How can this be resolved? The piece on copying the config file is missing there. Try adding the @docker:CopyFiles annotation as well. The following worked for me: @docker:Config { registry:"registry