1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License. See License.txt in the project root for license information.
3
4package automation
5
6import (
7	"fmt"
8
9	"github.com/Azure/azure-sdk-for-go/tools/internal/exports"
10)
11
12// ReadVersion reads the version of azure-sdk-for-go
13func ReadVersion(path string) (string, error) {
14	c, err := exports.Get(path)
15	if err != nil {
16		return "", err
17	}
18
19	version := ""
20	for k, v := range c.Consts {
21		if k == "Number" {
22			version = v.Value
23		}
24	}
25
26	if version == "" {
27		return "", fmt.Errorf("cannot get version number in package '%s'", path)
28	}
29
30	return version, nil
31}
32